Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Capturing Session TimeOut?  RSS feed

 
Sudharsan Govindarajan
Ranch Hand
Posts: 319
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
Is there any way to capture the timeout event of a session in JSP/Tomcat? I want to do some customized coding when a session times out.
Thanks in Advance
Sudharsan G
 
Anthony Villanueva
Ranch Hand
Posts: 1055
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Implement the sessionDestroyed(HttpSessionEvent se) method from the HttpSessionListener interface. According to the Servlet 2.3 docs, "implementations of this interface may are notified of changes to the list of active sessions in a web application. To recieve notification events, the implementation class must be configured in the deployment descriptor for the web application."
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It may be more convenient to implement the HttpSessionBindingListener - you don't have to declare it in the deployment descriptor.
If you attach an object implementing that interface to a session, the valueUnbound method will be called when the session times out. At that point the session will be invalid so you could attach all of the information you want to work on to the object that implements the interface.
Bill
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!