To test this i restarted Tomcat 6 then run access Servlet 1 first so that it initializes the Hashmap object. When i subsequently access Servlet 2 i get a NULL-POINTER error which is pointing at the line number where i tried to call newMap2.size()
I think you should ask yourself if these two web applications actually need to be separate applications in the first place. If they need each other's objects then they are tightly coupled and should perhaps be merged into one application.
While one application context cannot communicate internally with another, there are any number of ways two contexts could share information. A previous poster suggested a database for a persistence layer, which is a pretty common approach. Other options include reading / writing a local file both contexts would have access to, or even using HTTP to exchange data between the two contexts.
In preparing for battle I have always found that plans are useless, but planning is indispensable. -- Dwight D. Eisenhower
If we set the crossContext property to true, we can only access the resources such as servlets,jsps,other files in other web app. But we can't access session object in other context. We can write resource(servlet or jsp) which gives the info'n about the session object in other context.
posted 6 years ago
You can access and set data with set/get Attribute in context of other app.