Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials:
 

Software Solutions and Services
 

 
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification
  Java Applet
Questions
Comments
 
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.

 

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.

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 :

  • Wait for HTTP request.
  • Construct a ServletRequest object and a ServletResponse object.
  • If the request is for a static resource, invoke the process method of the StaticResourceProcessor instance, passing the ServletRequest and ServletResponse objects.
  • If the request is for a servlet, load the servlet class and invoke its 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:

  • When the servlet is called for the first time, load the servlet class and call its init method (once only).
  • For each request, construct an instance of javax.servlet.ServletRequest and an instance of javax.servlet.ServletResponse.
  • Invoke the servlet's service method, passing the ServletRequest and ServletResponse objects.
  • When the servlet class is shut down, call the servlet's destroy method and unload the servlet class.

Now lets see what a servlet container does for each HTTP request for a servlet, in general :

  • The servlet container loads the servlet class and calls the init method of the servlet as soon as the servlet is called for the first time.
  • Then this container makes an instance of javax.servlet.ServletRequest and javax.servlet.ServletResponse for each request.
  • Then it passes the ServletRequest and ServletResponse objects by invoking the servlet's service method.
  • Finally, it calls the destroy method and unload the servlet class when the servlet class is to be shut down.

                         

» View all related tutorials
Related Tags: c http browser class ant process post https methods servlet method sed get type const request constants content value return

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 

Current Comments

4 comments so far (
post your own) View All Comments Latest 10 Comments:

Hi,

I would really appreciate you guys to post this kind of simple yet easy to understand and crisp information at one place, I really really love to surf your site while I need some precise information about any (java/j2ee) topic.

Thanks once again to providing such a useful information

Posted by Rani on Thursday, 06.19.08 @ 10:40am | #63823

What is differance between web server and application server?

Posted by Biswomohan Pattanaik on Tuesday, 04.17.07 @ 12:14pm | #14416

really good ...today my doubts regarding are all clear.. thanks!!

Posted by Trinity_Meets_Neo on Friday, 04.6.07 @ 21:10pm | #13483

really super.
today i know exact ewhat the container means ?
thanks..

Posted by sagar on Wednesday, 02.28.07 @ 11:54am | #9931

Training Courses
Tell A Friend
Your Friend Name
Website Designing Services
 
Web Designing Packages From $150!
 
Website Designing Company Web Hosting
 
Website Designing Quotation
 
Search Tutorials:

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.