Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

sessionDestroyed() method of HttpSessionListener not getting called.

843844Apr 7 2007 — edited Apr 7 2007
I am using a HttpSessionListener. The problem is that the method sessionDestroyed() is not getting called when the session times out. It is also not called when the user closes the browser. Here is the code that I am using.
public class MyListener implements HttpSessionListener{
    public MyListener() {
    }
    
    public void sessionCreated(HttpSessionEvent sessionEvent){
        HttpSession session = sessionEvent.getSession();
        session.setAttribute("dogBreed","Labrador");
        session.setMaxInactiveInterval(30);
        System.out.println(session.getAttribute("dogBreed"));

    }
    
    public void sessionDestroyed(HttpSessionEvent sessionEvent){
        HttpSession session = sessionEvent.getSession();
        System.out.println("DogBreed : " + session.getAttribute("dogBreed"));
    }
}
What is wrong with the above code ?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 5 2007
Added on Apr 7 2007
3 comments
1,144 views