• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Session time out in Struts app

 
Raymond Miao
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 184
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
calvin zhu
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
just to say hello.
 
Raymond Miao
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks the RequestProcessor solution worked great!!
 
Raymond Miao
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 184
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There ya go buddy.
Glad that it worked well for you
-Srikanth
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic