How to do a simple session timeout?
2 posts in topic
Flat View  Flat View

Posted By:   Patrick_Wardhana
Posted On:   Tuesday, January 7, 2003 08:04 AM

Hi guys,

I'm here wondering how I can set a session timeout. Let's just say a user logs on to the web-app, and the web-app is implemented using servlets of course, and I would like to have the session expire after he stays on one page for over 15 minutes or something. I am using the request.getSession() function to get the unique session for the user. I know I can in validate the session during logout or something, but I would like to add the timeout feature. Does anyone have a suggestion on how to go about this? Do I need to create a timer function? Any help would be appreciated.


Re: How to do a simple session timeout?

Posted By:   vernon_wu  
Posted On:   Friday, January 10, 2003 11:40 AM

I believe the original question is how to timeout a session after it is up for a period of time, which is the same as a user signs in for the period of time; but not how to set timeout after the session is inactive for a period of time.

You need to use the Timer and TimerTask classes to implement this task.

Let me know how you're going during the phase.


Re: How to do a simple session timeout?

Posted By:   Christopher_Schultz  
Posted On:   Tuesday, January 7, 2003 08:54 AM

In WEB-INF/web.xml, use the following incantation:




It's one of the last sub-elements of . Check the DTD if you're unsure.

If this isn't in the FAQ, I'd be suprised, and it should be added.

Hope that helps,

About | Sitemap | Contact