This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSP and the fly likes Server 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 » Java » JSP
Bookmark "Server Session Timeout" Watch "Server Session Timeout" New topic
Author

Server Session Timeout

Kaustubh Hande
Greenhorn

Joined: Apr 10, 2007
Posts: 18
Hello,
Im working with JSP's in WSAD 5.0. The server session timout for my application has been set through the administration console. I was suppose to dsiplay an popup with message "Your session is about to expire" 2 min prior to the session expires and then as the session expires the message changes to "Your sessin has expired" to achieve this i used setInterval()method with interval as 30 min and setTimeout() methods of java in javascripts.Now comes the problem, as the second message is displayed and after i close the message pop up n then access ne other screen the session does not expire and allowes me to access other pages.
Does the setInterval() method that works in background stops the session from expiring even if there is no data sent or received from the server.
And is there ne way i can get the set server timeout into my application at runtime to set the interval in my setInterval() method.
Please help.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
1. You can override the default session lifetime with the HttpSession method:
setMaxInactiveInterval( int seconds )

2. You can then use the seconds value when writing Javascript into HTML pages to roughly synchronize the browser with the server.

3. ANY request to the server will cause the session timeout mechanism to reset and start counting down seconds again.

Bill
Kaustubh Hande
Greenhorn

Joined: Apr 10, 2007
Posts: 18
Thanks for that reply.

But my problem is that we have varios server at onsite where the application is being run and the session timeout for them is different according to the need, thus i cannot hardcode or set the session timeout value in my application. It would be a great favour if i can get to know how i can get the set server session timeout for a perticular server.
Please help

Thanks
Kaustubh
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

See:
http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/http/HttpSession.html#getMaxInactiveInterval()


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
It would be a great favour if i can get to know how i can get the set server session timeout for a perticular server.

Why not read it from web.xml as an init-param for an individual servlet or as a session-config parameter for the whole web app?

In the default web.xml for tomcat I find this entry:

after the last servlet-mapping element. Seems to me you should be able to override that default on a web app by web app basis.

Bill
 
Don't get me started about those stupid light bulbs.
 
subject: Server Session Timeout
 
Similar Threads
session timeout in firefox
Session never timesout in FF and IE7
Session timeout problem
setInterval() in JSP
Session Timeout handeling