有什么方法可以在tomcat的不同应用程序之间共享会话状态? [英] Any way to share session state between different applications in tomcat?

查看:36
本文介绍了有什么方法可以在tomcat的不同应用程序之间共享会话状态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们希望将一个工作应用程序拆分为两个不同的 .war 文件,以便能够在不影响另一个应用程序的情况下更新一个应用程序.每个 webapp 都有不同的 UI、不同的用户和不同的部署时间表.

We want to split a working application in two different .war files in order to be able to update one app without affecting the other. Each webapp will have different a UI, different users and different deploy schedule.

最简单的路径似乎是共享同一个会话,因此如果应用 A 设置 session.setAttribute("foo", "bar") 应用 B 将能够看到它.

The easiest path seems to be sharing the same session, so if app A set session.setAttribute("foo", "bar") app B will be able to see it.

有没有办法在同一个 Tomcat 实例中为两个应用程序共享 HttpSession 状态?

Is there a way to share the HttpSession state for both apps in the same Tomcat instance?

我们的应用程序运行在专用的 Tomcat 5.5 上,没有其他应用程序运行在同一个 tomcat 实例上,因此任何有关会话共享的安全问题都不是问题.我们正在运行多个 Tomcat 实例,但平衡器正在使用粘性会话.

Our app is running on a dedicated Tomcat 5.5, there are no other apps running on the same tomcat instance, so any security concerns regarding the session sharing are not a problem. We're running multiple Tomcat instances, but the balancer is using sticky sessions.

如果这是不可能的或者这个会话共享是一个非常糟糕的主意,请发表评论.

If it's not possible or this session sharing is a really bad idea please leave a comment.

推荐答案

您不应该共享 HttpSession;但您可以共享其他对象.例如,您可以通过 JNDI 注册一个对象 和访问所有应用中的同一个对象(数据库使用它来汇集连接).

You should not share HttpSession; but you can share other objects. For example, you can register an object via JNDI and access the same object in all your apps (databases use this to pool connections).

这篇关于有什么方法可以在tomcat的不同应用程序之间共享会话状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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