I'm trying to learn how JavaEE. I've previously used JSP a little but I've never messed with scopes and servlets.
I've got a servlet that is called when a user submits a form, and a UserBean bean is created & added to the session.
UserBean userBean = new UserBean();
userBean.setLogin(user);
userBean(setPassword(pass);
request.getSession().setAttribute("user", userBean);
RequestDispatcher dispatcher = request.getRequestDispatcher("/index.jsp");
dispatcher.forward(request, response);
This forwards me to index.jsp, on which I display the value that I just set... index.jsp is just this:
${sessionScope.user.login}
This prints whatever I set the username to in the form. That's correct. That's great. Now I go back to mysite.com/index.jsp by typing the URL (not just refreshing - that's fine) and the information has gone. There's nothing. My bean has been lost. I thought a session meant an extended period of time. How can I retain my beans after the user goes away for 30 minutes and comes back by typing my URL?
I'm messing with a user account system so I would want the user to be able to leave and come back a few minutes later and not have to log in again. Is there a scope for this? I tried switching from sessionScope to dependent, but no difference.