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 ?