RequestDispatcher forward between Tomcat instances

I have a script in which I have a Servlet access point and other servlets that are sent to perform this heavy processing.

I am considering distributing this download, and I would like to know if it is possible to use Tomcat or another platform to forward requests between servlets sitting on different servers using a cluster type configuration or similar.

I found some documentation on clustering Servlets and Tomcat, but none of them indicate whether it is possible to forward servlet requests from what I see.

http://java.sun.com/blueprints/guidelines/designing_enterprise_applications_2e/web-tier/web-tier5.html

http://tomcat.apache.org/tomcat-5.5-doc/cluster-howto.html

+6
java tomcat servlets
source share
1 answer

You can distribute it through webapps in a Tomcat clustered environment and add crossContext="true" to the <Context> element of the web pages in question. Here is an excerpt of the Tomcat Context Configuration Reference :

crossContext

Set to true if you want calls in this application prior to ServletContext.getContext() successfully return the request manager for other web applications running on this virtual host. Set to false (default) in security environments so getContext() always returns null .

Thus, you can get the desired RequestDispatcher as follows:

 RequestDispatcher dispatcher = getServletContext().getContext(name).getRequestDispatcher(path); 
+5
source share

All Articles