请教,当LoginServlet跳转到成功登陆页面后,如何将当前的登录用户名传递过去?
想使用session对象,但是貌似它是jsp的内置对象,写入doPost后不能被resolved。有什么好的办法呢?谢谢
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub Users user=new Users(); user.setUsername(request.getParameter("username")); user.setPassword(request.getParameter("password")); if ("admin".equals(user.getUsername()) && "password".equals(user.getPassword())){ response.sendRedirect(request.getContextPath()+"/login_success.jsp"); //session不能被resolved //session.setAttribute("username",request.getParameter("username")); }else{ request.getRequestDispatcher("/login_failure.jsp").forward(request, response); } }