File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Auto logout in Struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Auto logout in Struts" Watch "Auto logout in Struts" New topic

Auto logout in Struts

Deepak Lal
Ranch Hand

Joined: Jul 01, 2008
Posts: 561

How to implement Auto logout feature in Struts based application.?
Example: I have a simple Struts Application and i want it to Auto logout if session is inactive for 1 hr or currently no user is using my Struts based application for 1hr...Please advice Ranchers

When The Going Gets Tougher,The Tougher gets Going
Cesar Coz
Ranch Hand

Joined: Aug 19, 2010
Posts: 32
Hello Deepak,

this is what i would do.. i would add a filter to check the session when you make an 'action' and set the filter to expire the session if is inactive in 60m. If there's no session the app will redirect you to an error page

hope this will help you

Cesar Coz.
Deepak Lal
Ranch Hand

Joined: Jul 01, 2008
Posts: 561

How to implement in Struts 1.x ,Can you suggest/advice me on how to use a filter for above implementation.
Richard Golebiowski
Ranch Hand

Joined: May 05, 2010
Posts: 213

Can't you just set the session timeout in the web.xml file?
I agree. Here's the link:
subject: Auto logout in Struts
It's not a secret anymore!