I want to include the output of another servlet into the current response.
I can call
request.getRequestDispatcher("/new/url").include(request, response);
and it does go to the right servlet, but request.getPathInfo(), request.getServletPath() and friends do not get set to the new URL (they still have the old values), so the servlet does not work.
Is that supposed to be like that? And what can I do to make this work?
Yes, it’s supposed to be like that (from javadoc, note that Adeel Ansari cited javadoc for
forward()method instead ofinclude()):However, included servlet can access its own path info as request attributes with the following names: