如何在JSP上正确创建会话?
问题描述:
我在JSP上创建会话并设置属性userName,但我只能在第一页上获取此属性。当我转到下一页时,属性userName将丢失。我该如何解决这个问题呢?
I create session on JSP and set attribute "userName", but I can get this attribute only on first page. When I go to the next page, attribute "userName" is lost. How can I solve this problem ?
HttpSession session = request.getSession(true);
LoginManager loginManager = new LoginManager();
String name = loginManager.getUserName(request.getParameter("login"),
request.getParameter("pass"));
view = request.getRequestDispatcher("index.jsp");
session.setAttribute("userName", name);
view.forward(request, response);
我尝试session.setMaxInactiveInterval(600),但它没有帮助我。
谢谢!
I try session.setMaxInactiveInterval(600), but it did not help me.
thanks!