Flow of Web Application

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();
out.println(“Hello”);

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”)
view.forward(request,response);

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s