如何在一个Web应用程序上下文中访问另一个Web应用程序上下文

发布于 12-26 06:18 字数 475 浏览 4 评论 0原文

我在 Tomcat6 服务器中部署了两个 WAR,例如 Context-AContext 中的 WAR-AWAR-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 技术交流群。

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

发布评论

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

评论(1

三生殊途2025-01-02 06:18:17

“上下文A”不正确。传递给 getContext 的参数 是一个“uripath”。因此,如果您有 WAR-A (/war-a) 和 WAR-B (/war-b),则来自 WAR-B 的调用应该是

servletContext.getContext("/war-a");

注意:我为 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

servletContext.getContext("/war-a");

Note: the link I posted for getContext was from the Java EE 1.3 API, but it should not have changed.

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