【问题标题】:Why doesn't HttpRequest.getSession(true) get new session when old one null/invalid当旧会话为空/无效时,为什么 HttpRequest.getSession(true) 不获取新会话
【发布时间】:2017-07-06 19:06:24
【问题描述】:

谁能解释一下,当我运行这个java代码时:

    HttpSession session = request.getSession(false);
    if (session != null)
    {
            s_log.debug("Session has id: " + session.getId());
            session.invalidate();
    }
    s_log.debug("Request Session ID is: "+  request.getRequestedSessionId()); 
    s_log.debug("Request isRequestedSessionIdValid(): " + request.isRequestedSessionIdValid());
    HttpSession _session = request.getSession(true);
     s_log.debug("New Session is :" + _session.getId());

当当前请求会话为空且无效时,为什么我没有从 request.getSession(true) 获取新会话?我在日志中看到了这一点:

请求会话 ID 为:0000MYF8m5fpUjrzUHIp93yshSh:5e7fcdcf-2274-43bb-83d9-4d9b9a1d766a

请求 isRequestedSessionIdValid(): false

新会话是:MYF8m5fpUjrzUHIp93yshSh

【问题讨论】:

  • 另外,当我通过 Eclipse 在调试模式下运行 Websphere App Server 运行应用程序时,它会按预期获得一个新会话。但是,当我在非调试模式下使用 Websphere 在 eclipse 之外运行时,它不会获得新会话。

标签: session websphere httprequest


【解决方案1】:

这是被重用的会话 ID。实际会话正在失效并重新创建。

可以通过将 HttpSessionIdReuse 属性值设置为 false 来更改此行为。

【讨论】:

  • 我尝试通过将 server.xml 设置为具有 但它仍然重用会话 ID。我也尝试过使用 ,但也没有用。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-04-18
  • 2011-11-30
  • 2018-08-05
  • 2018-04-08
  • 2014-06-23
  • 1970-01-01
相关资源
最近更新 更多