Session timeout configuration not working?
As web.xml
I have it
<session-config>
<session-timeout>2</session-timeout>
</session-config>
<listener>
<listener-class>myapplication.SessionListener</listener-class>
</listener>
As SessionListener.java
I have
public void sessionDestroyed (HttpSessionEvent event){
System.out.println("Visitor Removed!!");
}
But it System.out.println("Visitor Removed!!")
never seems to have been performed. I am new to Tomcat 6 and JSP. Any suggestion please?
+2
a source to share
1 answer
This can have at least 3 reasons:
- The session was never created. Also listen
sessionCreated()
. - You are a little impatient. The session is destroyed lazily and at intervals. This does not happen immediately. If you start a new request in the same session while it has expired then will be called
sessionDestroyed()
. Or, if you have a little more patience, the server will start its own low priority timer job to get all the terminated sessions. - You are not using the class
myapplication.SessionListener
on the classpath as you think you are using, maybe the one in the classpath does not have a sysout line.
+6
a source to share