0

Due to some unavoidable issues, I am attempting to forward request on Appengine Java from one servlet to another. However, the "standard" config doesn't seem to work. I have:

web.xml

    <servlet>
        <servlet-name>MyServlet</servlet-name>
        <servlet-class>class.of.MyServlet</servlet-class>
    </servlet>

otherServlet.java

RequestDispatcher dispatcher = getServletContext().getNamedDispatcher("MyServlet");
dispatcher.forward(req, resp);

However, dispatcher is null (presumably because it can't find "MyServlet"), so I get an NPE.

This feels like a bug / non-standard implementation on the AppEngine side, but maybe I am missing something.

Tad
  • 4,668
  • 34
  • 35
  • Hi Tad. Do you get an error? If so, could you please share it with us to have more context about it? – Samuel Romero Dec 17 '20 at 02:30
  • There isn't an error - just null returned from `getNamedDispatcher()` - presumably indicating that it can't find the servlet. – Tad Dec 18 '20 at 04:50
  • What is the servlet API version you are using? If you are using a different one than 3.1, you can try that – Samuel Romero Dec 24 '20 at 22:49
  • I'm using 2.5. I'm working around it by just factoring out the shared code instead of forwarding the request, but I'll take a look. – Tad Dec 25 '20 at 00:13
  • are you using the java8 or java11 runtime? Could you include your `appengine-web.xml` or `app.yaml` according to your environment. Also include your `web.xml` with the servlets mappings – Emmanuel Dec 29 '20 at 19:03

0 Answers0