File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Session time out in Struts app Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Session time out in Struts app" Watch "Session time out in Struts app" New topic
Author

Session time out in Struts app

Raymond Miao
Greenhorn

Joined: Feb 26, 2004
Posts: 4
I am trying to define a general error page for session time out, when use type *.do I want to forward request to my predefined error page.
I have defined isSessionTimeOut methed in my action parent class to check session status, and in each action class I have:
if (isSessionTimeOut(request))
return mapping.findForward("error");
The problem is sometimes the action's execute method is not called as the validate method in ActionForm may return ActionErrors and request will be forwarded to the input page instead of my error page, has any one met this kind of situation before and had the solutions?
Thanks.
Srikanth Shenoy
author
Ranch Hand

Joined: Jan 24, 2004
Posts: 184
You might want to create your own RequestProcessor and override the processPreprocess() method.
In that method put your check for Session time out and then invoke doForward(uri, request, response) with time out page and return false from that method. else return true.
The Struts RequestProcessor calls the processPreprocess() in its process() method even before populating the ActionForm and doing other tasks like validation etc..
Hope this helps,
Srikanth Shenoy
[ February 27, 2004: Message edited by: Srikanth Shenoy ]

Srikanth Shenoy
Author of Struts Survival Guide : Basics to Best Practices
calvin zhu
Ranch Hand

Joined: Mar 18, 2002
Posts: 54
just to say hello.


SCEA, SCJD, SCWCD, SCBCD, SCJP<br />IBM WebSphere Portal certification
Raymond Miao
Greenhorn

Joined: Feb 26, 2004
Posts: 4
Thanks the RequestProcessor solution worked great!!
Raymond Miao
Greenhorn

Joined: Feb 26, 2004
Posts: 4
Another benefit is now I have single control point and I don't have to check session status in each action classes.
Srikanth Shenoy
author
Ranch Hand

Joined: Jan 24, 2004
Posts: 184
There ya go buddy.
Glad that it worked well for you
-Srikanth
 
 
subject: Session time out in Struts app
 
Similar Threads
Scoping issue
struts2 login interceptor not finding session attribute of user details.
How do I use tokens to prevent user from multiple submission
commons-fileupload
Dispatch VS LookupDispatch