Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

jsp + session timeout  RSS feed

 
Alex Kravets
Ranch Hand
Posts: 476
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
My web server uses its own session tracking and on the current set-up it times-out the session after 30 min. When the session is timed out, it dispays a NullPointerException, I guess because there is no session object anymore. Now, the message is displayed in the page where I was when my time-out occured. So if my current url is http://localhost/test.jsp that's where the exception will be displayed. Can I control through jsp directives where the user is redirected when session time-out occurs, or is this server specific issue and should be resolved through the web server admin utility?
thanks,
Alex
 
Adam Hardy
Ranch Hand
Posts: 567
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
whenever my session times out and i call up a page again, the only things that don't exist are stuff that i put in my session - you are getting the nullpointerexception because that doesn't exist, not because the session object doesn't exist.
put some error handling around your calls to the session object to check whether the stuff you wanted is still there or not, or whether the session object returned you some nulls.
then sort out the redirection yourself.
 
Mark Stringham
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can always ad a piece of JSP that will check to see if your session is still active or valid - basically check to see if a session var exists (!=null) and if it doesn't - redirect the user to another page -
<%
// check for session object
HttpSession validuser = request.getSession();
// check to see if session var exists
if (validuser.getValue("auth_user") == null) {
response.sendRedirect("admin3.jsp?access+denied");
}
// if the session var is null then redirect the user
Hope this helps
Mark
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!