管理不同 tomcat 实例上的会话

发布于 2024-09-06 04:49:24 字数 215 浏览 2 评论 0 原文

您好,我遇到的情况是,我在服务器上使用 4 个 tomcat 实例。当用户登录时,假设它连接到 tomcat-1,因此我们将所有会话值存储在 tomcat-1 中。然后我们正在处理 paypal。paypal 处理用户后被转移到另一个 tomcat 说 tomcat-2。所以这个用户的会话中没有值。而且我面临问题。所以我想在 paypal 处理后将用户发送到同一个 tomcat 上,以便他的所有会话值我们可以取。

Hi I am having scenario that I am using 4 tomcat instances on our server.When user login then suppose it is connected to tomcat-1 so we stored all session values in tomcat-1.Then we are processing paypal.After paypal processing user is get diverted to another tomcat say tomcat-2.So there are no values in session for this user.And I am facing problem.So I want to send user on same tomcat from where it comes after paypal processing so that his all session values we can fetch.

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

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

发布评论

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

评论(1

孤独患者 2024-09-13 04:49:24

为什么要在服务器中使用多个 Tomcat 实例?对此的最佳答案是使用单个 Tomcat 实例并在其上部署所有 Web 应用程序,如有必要,请使用 虚拟主机

如果您坚持使用多个实例,那么唯一的解决方案是将感兴趣的信息作为请求参数或路径信息传递并进行相应处理。如果此信息包含大量数据和/或复杂,则将其存储在共享数据存储(SQL 数据库?)中,并将其标识符(主键)值作为请求参数/路径信息传递。

如果您通过在服务器中使用单个 Tomcat 实例来解决此问题,则只需设置 emptySessionPath 属性即可doc/config/http.html" rel="nofollow noreferrer">HTTP 连接器 conf/server.xml 中设置为 true 。这样,HttpSession 将在所有已部署的 Web 应用程序之间共享。

如果您实际上有 4 台物理上独立的服务器计算机,每台 Tomcat 实例都包含 Web 应用程序的备份/副本,那么您需要创建一个 具有会话复制的集群

Why are you using multiple Tomcat instances in a server? The best answer to this would be to use a single Tomcat instance and deploy all webapps on it and if necessary make use of virtual hosting.

If you stick to using multiple instances, then the only solution is to pass the information of interest as request parameter or pathinfo and process it accordingly. If this information is lot of data and/or complex, then store it in a shared datastore (SQL database?) and pass its identifier (primary key) value around as request parameter/pathinfo.

If you solve this by using a single Tomcat instance in the server, then you can just set the emptySessionPath attrbute of the HTTP connector <Connector> in conf/server.xml to true. This way the HttpSession will be shared among all deployed webapps.

If you actually have 4 physically independent server machines with each one Tomcat instance which each contains a backup/duplication of the webapps, then you need to create a cluster with session replication.

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