Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Session Timeout

Status
Not open for further replies.

fatcodeguy

Programmer
Feb 25, 2002
281
CA
Hi,

I want to perform several tasks automatically when a session timesout (like update the usertable for last session duration). How can I do this?

Thanks
 
yoy may want implement a javax.servlet.http.HttpSessionListener to handle session event.

example
Code:
package yourPackage;

public class YourSessionEventListener implements javax.servlet.http.HttpSessionListener {

   public void sessionCreated(HttpSessionEvent se) {
      // do nothing for now.
   }

   public void sessionDestroyed(HttpSessionEvent se) {
      // Do you code here to update user session duration
      // .....
   }
}

and in the deployment descriptor, add the following defination before any <servlet> element

Code:
<listener>  
   <listener-class>yourPackage.YourSessionEventListener </listener-class>
</listener>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top