如何在一个Web应用程序上下文中访问另一个Web应用程序上下文
我在 Tomcat6 服务器中部署了两个 WAR,例如 Context-A
和 Context 中的
WAR-A
、WAR-B
-B 分别。
我已在 Context-A
中存储了一些数据,并且想在 Context-B
中读取该数据。
我已经通过网络找到了一些方法来实现它。我通过 cookie 将 Context-A
的会话 ID 提供给所有上下文。我也在 server.xml
中设置了 crossContext = true
。
但是,当我在 Context-B
中执行 serveltContext.getContext("Context-A");
时,它返回 null
。
I have deployed two WAR's in a Tomcat6 server, Say for example WAR-A
, WAR-B
in Context-A
and Context-B
respectively.
I've stored some data in Context-A
, and I want to read that data in Context-B
.
I have gone through the net and got some way to acheive it. I make the session ID of Context-A
available for all the contexts by cookies. And I have set the crossContext = true
in server.xml
too.
But when I do serveltContext.getContext("Context-A");
in Context-B
it's returning null
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

“上下文A”不正确。传递给 getContext 的参数 是一个“uripath”。因此,如果您有 WAR-A (/war-a) 和 WAR-B (/war-b),则来自 WAR-B 的调用应该是
注意:我为 getContext 发布的链接来自 Java EE 1.3 API,但它应该没有改变。
The "Context-A" is incorrect. The parameter passed to getContext is a "uripath". So if you have WAR-A (/war-a) and WAR-B (/war-b) the call from WAR-B should be
Note: the link I posted for getContext was from the Java EE 1.3 API, but it should not have changed.