What is Servlet chaining?
Servlet Chaining is a phenomenon wherein response Object (Output) from first Servlet is sent as request Object (input) to next servlet and so on. The response from the last Servlet is sent back to the client browser.
In Servlets, there are two ways to achieve servlet chaining using javax.servlet.RequestDispatcher:
RequestDispatcher rd = req.getRequestDispatcher("Servlet2");
2. Forward, where req is HttpServletRequest and resp is HttpServletResponse:
RequestDispatcher rd = req.getRequestDispatcher("Servlet3");