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. The Java Servlet and JavaServer Pages specifications are developed by Sun under the Java Community Process.
A container handles large number of requests as it can hold many active servlets, listeners etc. It is interesting to note here that the container and the objects in a container are multithreaded. 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.
We can categorize the servlet containers as:
I. A simple servlet container is not fully functional and therefore it can only run very simple servlets and does the following :
ServletRequest object and a ServletResponse
object.
process
method of the StaticResourceProcessor instance, passing the ServletRequest
and ServletResponse objects.
service
method, passing the ServletRequest and ServletResponse
objects. Note that in this servlet container, the servlet class is loaded
every time the servlet is requested.II. A fully functional servlet container additionally does the following for each HTTP request for a servlet:
init method (once only).
javax.servlet.ServletRequest
and an instance of javax.servlet.ServletResponse.
service method, passing the ServletRequest
and ServletResponse objects.
destroy
method and unload the servlet class.Now lets see what a servlet container does for each HTTP request for a servlet, in general :
|
Recommend the tutorial |




Ask Questions? Discuss: Servlet Container View All Comments
Post your Comment