Container:
Tomcat is the example of Container.
Container provides
b. Lifecycle Management:
c. Multithreading support
d. Declarative Security
e. JSP Support
Steps how container handles the request
1. get the HTTP request from the client
2. create HTTPServlet request and response.
3. Finds the correct servelt based on the URL and creates thread for each request.
4. Container calls the servlet’s Service() method, Depending upon type of request service method calls doGet() or doPost() method.
5. doGet() method generate the dynamic page and stuff in response object.
6. The thread completes the container converts response object to HTTP response and send to client and then delete the request and response object which it creates (in step 2).
Webserver do :
It gets the response from the container and converts the response object to an HTTP response.
It uses HTTP to talk to the client browser.
It knows how to forward the dynamic content to the container.
Servlet do:
It add the html to the response object
It has a name that matches the <Servlet-class> element in the DD.
Application server:
It will have/acts as web container and EJB container. J2EE, Weblogic, JBOSS,Websphere
Webserver:
Handles only HTTP request/response. Apache
Container:
It handles both HTTP and servlets and JSP. Tomcat.
How to pass the control to jsp from servlet:
a. RequestDispatcher
b. SendRedirect
Examples:
a. RequestDispatcher view = request.getRequestDispatcher(“result.jsp”);
View.forward(request, response);
b. response.sendRedirect(“www.google.com”); (it should have string as parameter).

