There is a servlet with such annotation @WebServlet ("/ *"). When I call req.getRequestDispatcher ("WEB-INF / jsp / pages / contact_list.jsp") in the method of the same servlet. Forward (req, resp); Then the same servlet is invoked on a new one, and then a servvet from JSP. Tell me how to avoid calling the first servlet.
1 answer
symbols /* - means that the action will be extended to any address that matches the mask /* , in fact, this is any address, be it /jsp/pages/contact_list.jsp or any other, if you only need to execute one page / , then you need to change the annotation to @WebServlet("/")
- I need to implement FrontController. Therefore, it is necessary to process all requests in one servlet. But I can’t figure out how to send a JSP to a client. - Alexander Natashkin
@WebServlet("/")just sets the default servlet ("default" servlet). To bind a servlet only to page/, you need to use@WebServlet(""). - Roman
|