Java:我丢失了会话:使用“”会出现问题吗?

发布于 2024-09-26 00:48:36 字数 156 浏览 0 评论 0原文

我在管理会话时遇到 Java 问题。一切都很完美(我在会话中创建并获取/设置值),直到我使用链接进行重定向(该链接位于 JSP 中)。然后,会话就会丢失。

我的服务器是Tomcat,浏览器是Firefox浏览器。我正在使用 Struts 2。

感谢您的宝贵时间;-)

I am having problems in Java while managing sessions. All works perfect(I create and get/set values in the session), until I redirect with a link (the link is in a JSP). Then, the session is lost.

My server is Tomcat, and my browser is a Firefox browser. I am using Struts 2.

Thanks for your time ;-)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

渔村楼浪 2024-10-03 00:48:36

自动删除会话的标准时间约为 30 分钟(例如在 Tomcat 中),但这取决于配置。

如果您编写 session.invalidate(),您的会话也会被删除。

如果您关闭打开会话的浏览器中的每个选项卡(即使您有使用同一浏览器的其他窗口),您的会话也会自动丢失。

您的链接位于同一应用程序服务器内吗?如果是的话,如果你不做我之前说过的事情,它就不应该丢失。

The standard time for the session to automatically get erased is about 30 minutes (for example in Tomcat), but it depends on the configuration.

If you write session.invalidate(), your session gets erased too.

Your session gets automatically lost if you close every tab in the browser you opened the session (even is you have other windows with the same browser).

Is your link inside the same application server? If it does, it shouldn't get lost if you are not doing things I said before.

牵你手 2024-10-03 00:48:36

如果您在导航器中接受 Cookie,则当您进入此页面时,您的代码可能会调用 invalidate()。还要检查过滤器。

If you accept cookies in your navigator, your code may call invalidate() when you go on this page. Check filters too.

涙—继续流 2024-10-03 00:48:36

一种可能性是您当前的会话 cookie 被标记为“安全”,并且“href”是“http:”链接。这将导致浏览器不发送 cookie,并且根据您的 web 应用程序结构,可能会自动创建一个新会话。

One possibility is that your current session cookie is marked as "secure", and the 'href' is an "http:" link. This will cause the browser to not send the cookie, and depending on your webapp structure a new session may then be created automatically.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文