1.Browser ->sends Request to Server -> Servlet Container — sees the URL and indentifies the Servlet from Web.xml Servlet Mapping, makes request object and spawns a new thread to handle this request and passes this request object to the thread made from servlets service method.
2. We can then set the response from servlet
PrintWriter out = response.getWriter();
3.Or We can use JSP to render view, JSP is on server side, so we can pass whatever is there in servlet to JSP via request. So, in Servlet we can set request.setAttribute(“test”,test);
4.Then in JSP we can get it request.getAttribute(“test”)
5. JSP willl be translated to a servlet and will be compiled, a view will be generated in response object and it will be passed to container.
6.Container will send this to browser over HTTP, browser only understands HTML.
7.We need RequestDispatcher to send this view to container.
RequestDispatcher view = request.getRequestDispatcher(“result.jsp”)