Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 547
Murugesh Avatar asked Dec 15 '25 16:12

Murugesh


1 Answers

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.

like image 137
Dave G Avatar answered Dec 17 '25 08:12

Dave G



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!