File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes Handling session time out in custom JSP error page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Handling session time out in custom JSP error page" Watch "Handling session time out in custom JSP error page" New topic
Author

Handling session time out in custom JSP error page

Rajendar Goud
Ranch Hand

Joined: Mar 06, 2002
Posts: 220
Hi,
iam using a custom jsp error page and its working fine,as iam displaying the error using
exception.getMessage().

But iam not able to handle the sessionTimeOut using this custom Error JSP page.
Could any one help me out or pass any suggestion?

Thanks
Raj
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

You could either test the isNew() property of the session or (as I do) test for the existence of an object that was put into session during the login.

Either way, once you've determined that the session is new, you could throw a new exception. This would end up forwarding the user to your custom error page.

Personally, since your code is aware of what the problem is at this point, I think it would be better to redirect the user to the login page with a message saying that their session has either timed out or that they've tried go directly to one of the application's pages without logging in first.

It's generally considered bad form to throw exceptions as part of flow handling.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Handling session time out in custom JSP error page