8/15/15

Access context of other web application

Tomcat : Accessing context of other web applications


Readers, At some point you require to access the context of another web application. It is possible but comes with certain rules.

You can get context of the web application running on the same tomcat server and virtual host. You need to go to your tomcat server imported in eclipse under Project Explorer.
go to servers -> tomcat -> context.xml and open context.xml

Make  <Context crossContext = "true" > and save, restart tomcat.

This will allow your web application to interact with other applications deployed at tomcat server.

To Access context of another application use

   getServletContext().getContext("/your-other-web-application-name")

you need to give another web application name, whose context you want to access.