Access session of another web application

2019-02-13 09:09发布

Is it possible to configure two separate web apps (WAR) in a J2EE application (EAR) to access a shared session context?

Further info:

I ended up creating a shared class from the EAR which stored the required information in static members. This did the trick, even if it seemed like a dirty hack.

3条回答
等我变得足够好
2楼-- · 2019-02-13 09:34

As far as i've read and seen, it is not possible to share sessions across different webapps. You can only serialize a session for transfer between instances of the same webapp.

查看更多
Anthone
3楼-- · 2019-02-13 09:42

Not directly. Most containers put each WAR in a separate classloader with the EAR classloader as their parent. Each app's sessions are separate. You can put something provided by the parent EAR in each session. If you need them to share something, make it a EAR function.

查看更多
再贱就再见
4楼-- · 2019-02-13 09:43

There is no "standard" solution to this. However, many application servers have their own extensions for this. WebSpere has a "Shared session context" option for example.

See here: http://publib.boulder.ibm.com/infocenter/wasinfo/v6r0/index.jsp?topic=/com.ibm.websphere.base.doc/info/aes/ae/tprs_sharing_data.html

查看更多
登录 后发表回答