Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Server Session Timeout

 
Kaustubh Hande
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13071
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13071
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic