There is a servlet myServlet and a filter MyFilter , which intercepts the call to the servlet. After the filter, as I understand it, I must first work out the servlet, after which it transfers control to jsp , but I don’t understand how to transfer control to it?

I only get from the filter to immediately issue jsp , if I redirect the request like this:

 request.getRequestDispatcher("myJsp.jsp").forward(request , response); 

In the servlet, you need to do a couple of important calculations.

    1 answer 1

    After the filter has performed all the necessary actions, simply transfer control further along the chain:

     public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { // Выполняем действия... // Передаем управление далее chain.doFilter(request, response); } 

    The last item in the chain will be the servlet.

    • it doesn't work like that .. - dzrkot
    • damn I redefined only doGet (), thanks, understood - dzrkot