I have a configuration where Tomcat is front by Apache.
I have a servlet that is mapped to the all path under the webapp root context (e.g) :
This would effectively trap all requests to be serviced by MyServlet.
I would like for MyServlet to detect the request coming in , and if it is a PHP request , reroute the whole request (including request parameters and session) to be handled by PHP engine (or perhaps , hit Apache which have PHP installed). Is there a way to do this ?
By doing a servlet redirect or dispatch is definitely not working as it will cause an infinite loop!
If I understand correctly, you have Apache on the frontend, and it forwards requests to tomcat. You should be able to configure apache to forward everything to tomcat, but keep all php requests for itself. If that is not a valid option, then another thing to do is to redo your servlet mapping or to handle the forward inside your servlet.
Unfortunately I do not have access to Apache , hence I would not be able to do any tweaking to it.
I am actually looking at the last option og handling the forward in the servlet. But how can I do that without ending up in a recursive call ?
See for example Redirect filter in JSOS:
There is no infinite loop.