Web tier: servlets, JSP, Web frameworks: Servlet rerouting request to PHP interpreter

  1. Servlet rerouting request to PHP interpreter (3 messages)

    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!

    Thanks !

    Threaded Messages (3)

  2. tomcat and apache[ Go to top ]

    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.
  3. tomcat and apache[ Go to top ]

    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 ?
  4. tomcat and apache[ Go to top ]

    See for example Redirect filter in JSOS:

    There is no infinite loop.