SERVLET CONTAINER

WEB CONTAINER
Web container (also known as a Servlet container) is the component of a web server that interacts with Java servlets. A web container is responsible for managing the lifecycle of servlets, mapping a URL to a particular servlet and ensuring that the URL requester has the correct access rights. A web container implements the web component contract of the Java EE architecture, specifying a runtime environment for web components that includes security, concurrency, lifecycle management, transaction, deployment, and other services.


A servlet container is nothing but a compiled, executable program. The main function of the container is to load, initialize and execute servlets. The servlet container is the official Reference Implementation for the Java Servlet and JavaServer Pages technologies.
A Container have the capacity of containing many servlets and can handle large number of requests. The Container and the Objects of the container both are multi-threaded. It can handle multiple requests concurrently. All the servlets are managed by servlet container.So each object must be thread safe in a container as the multiple requests are being handled by the container due to the entrance of more than one thread to an object at a time.
Note : A Servlet container may run stand alone i.e. without a web server or even on another host.
Servlet Container
The Container does the following thing- 
  • When the request comes at first for the servlet, then it load the servlet, initialize it by calling servlet init() method.
  • Makes a thread of the requested servlet
  • Makes an instance of ServletRequest and ServletResponse of javax.servlet.*; package
  • Passes the ServletRequest and ServletResponse reference variables to the servlet service method
  • Take the ServletResponse object from the servlet and passes to the web server
  • And finally destroy the reference variables and destroy the servlet when the is shut down.


Comments

Popular posts from this blog

Servlet Advantages and Disadvantages

The Deployment Descriptor: web.xml

Session Management