Servlet Container

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.

The servlet container together with the web server (or application server) provides the HTTP interface to the world. It is also possible for a servlet container to run stand alone (without web server) or to even run on another host than the web server. When a request is received by the servlet container, it decides what servlet to call in accordance with a configuration file. The servlet Container calls the servlet's service() method and passes an instance of ServletRequest and ServletResponse. Depending on the request's method (mostly GET and POST), service calls doGet() or doPost().

These passed instances can be used by the servlet to find out who the remote user is, if and what HTTP POST parameters have been set and other characteristics. The servlet container is responsible for loading and instantiating the servlets and then calling init().

The container is designed to perform well while serving large numbers of requests. A container can hold any number of active servlets, filters, and listeners. Both the container and the objects in the container are multithreaded. The container creates and manages threads as necessary to handle incoming requests. The container handles multiple requests concurrently, and more than one thread may enter an object at a time. Therefore, each object within a container must be threadsafe.


Enter your email address to get our daily JOBS & INTERVIEW FAQ's Straight to your Inbox.

Make sure to activate your subscription by clicking on the activation link sent to your email