HttpSessionListener未检测到会话超时 [英] HttpSessionListener not detecting session timeout

查看:571
本文介绍了HttpSessionListener未检测到会话超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个javax.servlet.http.HttpSessionListener的实现,它应该检测Struts项目中的用户会话失效/超时。

I have an implementation of javax.servlet.http.HttpSessionListener that is supposed to detect user session invalidation/timeout in a Struts project.

sessionDestroyed()从不似乎被调用,我可以通过删除我的JSESSIONID并刷新页面来重现这一点。我还发现打开浏览器直到会话超时具有相同的效果。

The sessionDestroyed() never seems to be getting called, I can reproduce this by deleting my JSESSIONID and refreshing the page. I also find that leaving the browser open until the session times out has the same effect.

该站点在JBoss 4.2.3.GA中运行,带有Java 1.5。

The site is running in JBoss 4.2.3.GA with Java 1.5.

我开始怀疑HttpSessionListener不能达到我的预期,我错过了什么吗?

I'm starting to suspect that HttpSessionListener does not do what I expect it to, am I missing something?

修改:

我的监听器在我的web.xml中注册如下:

My listener is registered in my web.xml as follows:

<listener>
    <listener-class>com.domain.web.listener.LogoutListener</listener-class>
</listener>


推荐答案

sessionDestroyed()<在Web容器到期会话之前,不会调用/ code>方法。服务器不知道您删除了 JSESSIONID cookie,您的浏览器看起来就像是另一个新会话。

The sessionDestroyed() method is not called until the web container expires the session. The server doesn't know you deleted the JSESSIONID cookie, your browser just looks like another new session.

来自我在Tomcat看到的,我相信这取决于每个Web容器的实现,会话到期每分钟都会发生。因此,即使在会话超时之后,可能会有延迟,直到下一次检测到到期。

From what I've seen with Tomcat, and I believe it's up to each web container implementation, session expirations happens every minute. So even after the session times out there could be a delay until the next detection of expirations.

它最终应该会发生。特别是如果您将超时设置为一分钟并等待几分钟。请注意,超时以分钟为单位指定,因此一分钟是测试的最小值。我假设您在 web.xml 文件中注册了您的监听器?

It should definitely happen eventually though. Especially if you set the timeout to a minute and wait a few minutes. Note the timeout is specified in minutes, so one minute is the minimum to test with. I assume you have your listener registered in your web.xml file?

这篇关于HttpSessionListener未检测到会话超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆