Reputation: 1310
I've had experience forwarding requests between separate webapps by updating each webapp's META-INF/context.xml to contain crossContext="true".
However, I have a situation now where I have webapps deployed within the same running tomcat but in entirely separate areas. To elaborate, in tomcat's server.xml:
If I run these webapps within the same host, I can dispatch requests between the two via their context.xml's crossContext="true" and obtaining the relevant servlet context to forward the request to (as per Tomcat not able to get ServletContext of another webapp).
However, is this possible to dispatch between two webapps that essentially have to run on separate ports (without putting httpd or somesuch in front of tomcat)?
Upvotes: 0
Views: 874
Reputation: 597254
Not in a native way, which is probably good.
You can access then by generating http requests from one to the other. For that purpose you need each of them expose some functionality over http (perhaps RESTfully). In order to make the requests you can use apache http components, or simply URL.openConnection()
. You will just need to supply the URL (+port) of other apps to the application, so that they can make the invocations.
Upvotes: 0