How to access the one Web application Context in another Web application Context

╄→гoц情女王★ 提交于 2020-01-04 02:19:36

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/8834016/how-to-access-the-one-web-application-context-in-another-web-application-context

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!