wood burning stoves 2.0*
The moose likes Struts and the fly likes how to handle session timeout Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "how to handle session timeout" Watch "how to handle session timeout" New topic
Author

how to handle session timeout

debraj mallick
Ranch Hand

Joined: Mar 08, 2011
Posts: 188

hi all,
i have web.xml like

so all my data stored in session will expire after 15min, I have stored userId and userName in session but the problem is-
I am not able to understand from clentside whether my session data are still available or not, so when i hit any button or links, I got exception because I don't have my userId is session (userId is needed),

How can i solve this, so that after session is expired, user is redirected to login page automatically or after hitting any links or buttons on the page.
Sudhakar Sharma
Ranch Hand

Joined: Apr 04, 2009
Posts: 71

Check the session inside your filter or servlet(central controller) first, if the session is new and the request for a resource that is not accessible without login, send the login-page to the user or else send him the resource.
debraj mallick
Ranch Hand

Joined: Mar 08, 2011
Posts: 188

Hi Sudhakar,

the code i have used while inserting data into session is like

Check the session inside your filter or servlet(central controller) first

do i have to use interceptor?
i didn't understand, put some code to make me understand.
ok, i can check if session is null or not like

then how to redirect to any jsp page.

any help would be appreciated.
Sudhakar Sharma
Ranch Hand

Joined: Apr 04, 2009
Posts: 71

Hi debraj,

I think interceptor pattern is useful when your application requires logging or checking of the request, In your scenario your want to check for the session, so it might be the servlet or filter who is invoked first, check in this servlet whether the session has user_id or not and forward to the corresponding pages.

thank you
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to handle session timeout
 
Similar Threads
Tomcat HttpSession inactivity
WEB-INF/web.xml-help
Session timeout not working
session is not invalidating
WEB-INF/web.xml-help