RequestDispatcher forward between Tomcat instances

前端 未结 1 820
予麋鹿
予麋鹿 2021-02-09 21:43

I have a scenario where I have single entry point Servlet and further Servlets that requests are forwarded to that undertake heavy processing.

I am looking at options to

1条回答
  •  被撕碎了的回忆
    2021-02-09 22:39

    You could distribute it over webapps in a clustered Tomcat environment and add crossContext="true" to the element of the webapps in question. Here's an extract of Tomcat's Context Configuration Reference:

    crossContext

    Set to true if you want calls within this application to ServletContext.getContext() to successfully return a request dispatcher for other web applications running on this virtual host. Set to false (the default) in security conscious environments, to make getContext() always return null.

    This way you can obtain the desired RequestDispatcher as follows:

    RequestDispatcher dispatcher = getServletContext().getContext(name).getRequestDispatcher(path);
    

    0 讨论(0)
提交回复
热议问题