Example & Tutorial understanding programming in easy ways.

What are common tasks performed by Servlet Container?

Servlet containers or web container are also known as web container, for example Jakarta TomCat, WebLogic, JRun etc,in which the Web application containing the servlets is deployed invokes the servlets. Java servlets are not user-invokable applications. Some of the important tasks of servlet container are:


The web container providers implement most of the interfaces and classes of the Java Servlet API. When a servlet is being invoked, the Web container exchanges the incoming request information with the servlet, so that the servlet can analyze the incoming request, and generate responses dynamically. The Web container in turn interfaces with the Web server by accepting requests for servlets, transmitting responses back to the Web server.


Communication Support:- The servlet container provide the medium for inter servlet comunications and to the clints its browsers also. It perse the user request and generate the dynamic responses for the user. The all comlexity is get handled by the web servlet conainer. We do`t need to imlement the server socket layer to listen the clients requests. We need to focus on the business logics only.


Lifecycle and Resource Management: The life cyclee and all releated methods and instances get persed and handled by the web container by itself . The web container also provides utility like JNDI for resource pooling and management.


Multithreading Support: Container creates new thread for every request to the servlet and provide them request and response objects to process the request. So servlets are not initialized for each request. It shares the common one time memory for each request and saves time and memory.


JSP Support: JSPs doesn’t look like normal java classes. It looks like an HTML document but every JSP in the application is compiled by container and converted to Servlet and then container manages them like other servlets and get inter linked between the servlets by the web.xml deployer.


There are so many technologies for generating dynamic Web pages, such as CGI, NSAPI, ISAPI. from all of them the servlet framework provides a better abstraction of the HTTP request-response model by specifying a programming API for encapsulating requests, responses, sessions, beans etc.


Servlet instances can persist that much long across client requests, servlets have all the advantages of the Java programming language so the server is not constantly spawning external processes. Java servlet-based applications can be deployed on any Web server.  

Read More →