Web Application Architecture: Container

Web Application Architecture: Container
-------------------------------------------------

A Servlet doesn’t have a main method, but it still can be used, we run it, and use the Request and Response objects. Who will create the Servlet methods and who will create the Request and Response objects? The answer is the Container.
The container is an application on Java which controls the Servlet. His roles are:
   -Communication Support: Our Servlet will talk with the web without creating a socket, without setting a port, all of that are done by the container.
   -Life cycle: Servlet are supposed to be java class but we never create their object and never call their methods.
   -Multithreading support: Each time the container receive a request, it will start a new thread and complete it after the running the HTTP method for that client request.
   -Declarative security: The container itself will determine if the client is a sure and secure one.
   -JSP Support: The container will change the JSP code into real Java.


How a container handles a request?
   1.Get the request from the user by te URL
   2.Create the HttpServletResponse and HttpServletRequest objects
   3.Find the correct Servlet based on the URL
   4.Call the method of service (doGet() or doPost())
   5.Generate the dynamic page
6. Send the response object in the Http Response and delete the Request and Response objects.

你可能感兴趣的:(java,jsp,Web,servlet,container)