Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Controlling Session Timeout in JSP

 
Bhavik Patel
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hii there...
I want to put some kind of Alert Popup on JSP Page that occurs when there is 10 minute left in session time out...let's say i have specified 30 min as session timeout in web.xml file.If user doesn't do anything for 20 mins ..then i want to pop up a alert (for example -- You are not doing anything so the session will expire in 10 mins )..How to do that ???
[ September 13, 2005: Message edited by: Bear Bibeault ]
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34095
337
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bhavik,
When the page loads, start a timer in javascript. After 20 minutes, have it pop up an alert.
 
Bhavik Patel
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i don't want to put JUST an alert after 20 mins..i want to check and make sure no activity is done in last 20 mins and if that's the case pop an alert...
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A filter that intercepts every request, and updates a timestamp in a session scoped bean would provide the server side to this solution.
Have your javascript function call a servlet that checks this bean after 20 minutes.

Of course the act of checking is, in itself activity.
It wouldn't be hard, though to exclude checks to to that servlet when updating the timestamp.
 
Deepa Korecherla
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use session.getCreationTime() which gives the time the session was created. Add the max. session time to it and subtract 10mins from it and take that time as x. when this time x is reached give the pop-up.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64632
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i want to check and make sure no activity is done


What consititutes 'activity'? Moving the mouse? Client-side events?

What you're trying to do makes no sense to me since any non-client activity will extend the session timeout.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic