aspose file tools*
The moose likes Servlets and the fly likes Introduction Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Introduction" Watch "Introduction" New topic
Author

Introduction

rosy leena
Greenhorn

Joined: Dec 21, 2012
Posts: 2
hi
my name is rosy I Want Servlet Life Cycle Process.Can you provide these details.

thank you

rosy

J. Kevin Robbins
Bartender

Joined: Dec 16, 2010
Posts: 1038
    
  13

Google is your friend.

And welcome to the Ranch.


"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." -- Ted Nelson
sunny ranjan
Greenhorn

Joined: Dec 21, 2012
Posts: 6
SERVLET LIFE CYCLE

At server start-up

When you start the web-server[like tomcat] then web-container will be started and following tasks will occur on start-up:

1.Container reads the data from web.xml[using SAX parser] and stores that data in the main-memory.[Jvm]
2.Container creates the Servlet-context object and initializes the Servlet-context object with context parameters specified in web.xml.
3.Thread pool will be created by the container.
4.All the Filters and Listeners will be initialized.
5.container checks whether any servlet is configured with <load-on-startup> tag the that servlet will be initialized.

while initializing any servlet at start-up following events occur:
1.Servlet class will be loaded.
2.Servlet instance will be created by calling the default Constructor.
3.Container creates the Servlet-config object and initializes the Servlet-config object with context parameters specified in web.xml.
4.Container calls the init() method by passing Servlet-config as a parameter.
NOTE: Anyhow servlet is initialized above said tasks will happen at each servlet start-up.

WHEN you SEND THE FIRST REQUEST TO A SERVLET FOLLWING EVENTS HAPPEN:

1.Container picks the thread from the pool and assigns the request processing.
2.Now thread will start the request processing as follows:
(A)It creates the HttpServletRequest object and initializes the HttpServletRequest object with the data coming from client(like request parameters,request headers,request cookies etc..)
(B) creates the HttpServletResponse object and initializes the HttpServletResponse object with IO Stream.
(C)calls the service() method of servlet with request and response object as parameters.
(D)Once the service method execution is done then stream associated with response object will be taken and flushed to the client over network.

3.Container returns the thread to the pool after request processing is finished.

AT THE SHUTDOWN OF SERVER FOLLOWING TASKS HAPPEN:
1.Servlet-context object will be destroyed
2.Thread pool will be destroyed.
3.Container invokes the destroy() method for all servlets.
4.Container invokes the destroy() method for all filters.
5.All listeners will be destroyed.
6.All others running objects inside the container will be destyoyed and finally container is down and unable to process any user request.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Introduction