This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Session Events Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Session Events" Watch "Session Events" New topic
Author

Session Events

Ricardo Cortes
Ranch Hand

Joined: Jan 23, 2002
Posts: 140
The following is from the servlet 2.3 specification. Could someone please inform me just how one can tell whether a session was invalided because the session timed out or the application called invalidate?
"Listener classes provide the developer with a way of tracking sessions within a web application. It is often useful in tracking sessions to know whether a session became invalid because the container time out the session, or because a web component within the application called the invalidate method. The distinction may be determined using listeners and the HTTPSession API methods".


Sun Certified J2EE Architect for the J2EE Platform (Part 1)<br />Sun Certified Web Component Developer for the J2EE Platform<br />Sun Certified Programmer for the Java 2 Platform
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
The HttpSessionEvent gives you the HttpSession that is being destroyed. You can then compare (System.currentTimeMillis() - session.getLastAccessTime())/1000 with session.getMaxInactiveInterval() and determine whether the session has expired. If not, it must have been invalidated.
- Peter
[ May 02, 2002: Message edited by: Peter den Haan ]
 
 
subject: Session Events
 
Similar Threads
Hibernate Session Best Practice
j2ee application instance in tomcat container
Session lost in Tomcat when POST is done from a remote computer
Session count tracking is lost when Tomcat restarted
Session tracking with model 1