| Author |
Controlling Session Timeout in JSP
|
Bhavik Patel
Ranch Hand
Joined: Jul 12, 2004
Posts: 155
|
|
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 ]
|
SCJP 1.4<br />SCWCD 1.4(91%)<br />Working on SCJD -Bodgitt & Scrapper Constructions...<br /> <br />"It takes 43 muscles to frown & 17 to smile but it doen't take any to just sit there with a dumb look on your face .. Keep Smiling "
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26213
|
|
Bhavik, When the page loads, start a timer in javascript. After 20 minutes, have it pop up an alert.
|
[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
|
 |
Bhavik Patel
Ranch Hand
Joined: Jul 12, 2004
Posts: 155
|
|
|
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
Joined: Dec 11, 2004
Posts: 13410
|
|
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.
|
Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
|
 |
Deepa Korecherla
Ranch Hand
Joined: Jul 14, 2004
Posts: 197
|
|
|
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.
|
DKR<br />SCJP1.2,SCWCD1.4,SCBCD1.3,SCJA
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56229
|
|
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.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
 |
|
|
subject: Controlling Session Timeout in JSP
|
|
|