1 Reply Latest reply on Nov 20, 2009 7:07 PM by aravindkosuri

    While Session Expire Call One Method

      While Session Expire, i need to Call One Method... Normally when i click Logout, it will calls one method, the user status also set to logged out, then the session will also expire,.,.,But in this case, suppose the user directly closing the window means, after sometime the session will automatically expire, at that time i have to do changes in database(i.e.Updating the status for that user)...



      Thanks in advance,
      Seetharaman.G

        • 1. Re: While Session Expire Call One Method
          aravindkosuri

          Write a HttpSessionListener class and override sessionDestroyed method the way you want.


          Declare your listener class in web.xml like below.


          <listener-class>
          com.abc.geps.session.UserSessionListener
          </listener-class>
          
          Session Lister class template
          
          public class UserSessionListener implements HttpSessionListener {
          public UserSessionListener() {
          }
          public void sessionCreated(HttpSessionEvent event) {
          System.out.println(“Session created");
          
          }
          public void sessionDestroyed(HttpSessionEvent event) {
          // Your code goes here
          }