【问题标题】:Httpsessionlistener: two sessions are created and none are destroyedHttpsessionlistener:创建了两个会话,没有一个被销毁
【发布时间】:2013-02-16 12:06:28
【问题描述】:

编辑:我重新提出了问题

我正在使用SpringGWTEventService(与Comet 基本相同)。当我制作一个更简单的 HttpSessionListener 时,我看到 sessionCreated() 被调用了两次,而 sessionDestroyed() 没有被调用。这是为什么?一个用户有两个会话吗??? 第二个 HttpSession 是在我第一次在会话 bean (Spring) 上设置一些信息时创建的。

import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;
 
public class SomeSessionListener implements HttpSessionListener {
 
  @Override
  public void sessionCreated(HttpSessionEvent se) {
    log.info("New session was created, source= " + se.getSource());
  }
 
  @Override
  public void sessionDestroyed(HttpSessionEvent se) {
    log.info("A session was closed");
  } 
}

示例输出:

Application has started
New session was created, source= org.mortbay.jetty.servlet.HashSessionManager$Session:21u4n0rnyp4i@24662444
New session was created, source= org.mortbay.jetty.servlet.HashSessionManager$Session:n9wm8tsj1ote@28925695
Application interrupted by client

【问题讨论】:

    标签: spring comet server-push httpsession


    【解决方案1】:

    我找到了针对不同问题的答案: Spring security concurrent-session and HttpSessionListener problem

    简而言之: 最好对会话 bean 使用销毁方法。

    【讨论】:

      猜你喜欢
      • 2016-08-09
      • 2016-12-24
      • 2015-03-25
      • 1970-01-01
      • 2015-08-16
      • 2016-04-01
      • 2019-01-26
      • 1970-01-01
      • 2015-03-21
      相关资源
      最近更新 更多