Using tomcat 7, servlet 3.0, spring mvc3 with spring social, I get my class to listen sessions with;
public class AClass implements ApplicationContextAware, HttpSessionListener{
...
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.applicationContext = applicationContext;
if (applicationContext instanceof WebApplicationContext) {
((WebApplicationContext) applicationContext).getServletContext().addListener(this);
}
public void sessionCreated(HttpSessionEvent se) {
System.out.println("session created");
}
public void sessionDestroyed(HttpSessionEvent se){
System.out.println("session destroyed");
}
...
}
and I set the session-timeout to 1 minute in web.xml (I am sure it is working correctly) When I open a page I get the 'session created' message but I never get 'session destroyed'. If I refresh the page after 1 minute I get the 'session created' message again which claims that session is getting expired.
So the question is what am I getting wrong? Shouldn't sessionDestroyed method notify me when a session gets expired?