Reputation: 1001
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
.
Upvotes: 3
Views: 2469
Reputation: 9767
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.
Upvotes: 3