Servlet2 must be without any mapping in annotations or in web.xml.
Then you cannot use HttpServletRequest#getRequestDispatcher(String)
, which is a container managed method that checks those mappings.
That condition is ridiculous and makes no sense. If you aren't going to use the Servlet container, don't make a Servlet
. Make a service class that performs the actions you need. You don't need to make everything a Servlet
.
Your only (ridiculous) alternative is to instantiate Servlet2
and explicitly invoke its doGet
method.