Hi, Andy-
I'd suggest looking at:
ServletContext.getContext
and comparing:
ServletContext.getRequestDispatcher with
ServletRequest.getRequestDispatcher
Hope that helps.
-Terence Bandoian
On 8/11/2023 2:52 AM, Andy Pont wrote:
Hello!
We have a commercial application that runs under Tomcat 8.5.65 (on
Windows Server 2019). In the tomcat/webapps directory there are the
following three directories (names changed):
backend
frontend
ROOT
The “frontend” directory contains the UI for the commercial
application and is, as far as I can tell, all just HTML, JavaScript,
etc. The “backend” directory contains the parts of the system that do
the bulk of the work and appear to be mainly .jsp files.
Amongst other things, the “backend” handles a URL
https://<server_name>/backend/rest/abc/xx where “xx” represents a
number that tells it what to act upon.
I have started developing a new servlet which handles POST requests to
the URL: https://<server_name>/plugins/abc/xx. In some cases (based on
a values in the request body), the servlet will process things itself
and generate its own response. For certain cases it just needs to
forward the request on to corresponding “backend” URL and then pass
the response back.
I assumed that .forward(request, response) on a RequestDispatcher
would be what I needed to use. I have tried every combination of
getServletContext() and getRequestDispatcher() I can think of or have
found on the internet but it always fails with an HTTP error 404.
This is because the URL that it is being forwarded to always has a
rogue “plugins” in it, i.e.
https://<server_name>/plugins/backend/rest/abc/xx.
I suspect the solution is simple but I am new to Tomcat and developing
servlets and probably missing something obvious. Any guidance would
be much appreciated.
-Andy.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org