开发者

Session-timeout configuration doesn't work?

In web.xml I have this

 <session-config>
   <session-timeout>2</session-timeout>
 </session-config>

 <listener>
  <listener-class>myapplication.SessionListener</listener-class>
 </listener>

In the SessionListener.java I have

public void sessionDestroyed (HttpSessionEvent event){    
   System.out.println("Visitor Removed!!");
}

But it seems System.out.pr开发者_如何学编程intln("Visitor Removed!!") has never been executed. I am new to Tomcat 6 and JSP. Any suggestion please?


This can have at least 3 causes:

  1. The session has never been created. Listen on sessionCreated() as well.
  2. You are a bit impatient. Session destroy happens lazily and at intervals. It does not happen immediately. If you fire a new request in the same session while it has been expired, then sessionDestroyed() will be called. Or if you have a bit more patience, the server will run its low-prio timer job to reap all expired sessions.
  3. You are not using the myapplication.SessionListener class in the classpath as you think you're using, maybe the one actually in the classpath doesn't have a sysout line.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜