This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Servlets and the fly likes Servlet Lifecycle Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet Lifecycle" Watch "Servlet Lifecycle" New topic
Author

Servlet Lifecycle

Rajendra Prakash
Ranch Hand

Joined: Sep 10, 2009
Posts: 293
What i read about servlet life cycle is
1.once the request made to servlet means, servlet mapped through web.xml file and
particular servlet class loaded in to memory
2. New instance will be created (how , who creates instance)
3. container calls init(), it is called only once throghout the life cycle of servlet
4. then service method called to handle the client request. service method called for each time
i know multiple requests and handled by thread.
5. Finally , if the instance will not be accessed for long time or server shutdown means,
container removes instance by destroy().

Interviewer asked , two requests are waiting which one will be processed.
I am clear about lifecyle.
In HTTPServlet service() method called before doGet(), doPost() or not
subhash kumar
Ranch Hand

Joined: Jul 14, 2010
Posts: 63
two requests are waiting which one will be processed.

i think there no queue for the request by which two request can be thought of waiting
it is just the thread pool from which a thread will be assigned to process the request
so unless that thread pool got exhausted all request will be processed.


Subhash Kumar
Attitude is everything
Manjusha Muraleedas
Ranch Hand

Joined: Jun 02, 2010
Posts: 52
New instance will be created (how , who creates instance)

By the container


Finally , if the instance will not be accessed for long time or server shutdown means,
container removes instance by destroy().


destroy() will be called before the servlet being unloaded from memory.This method can be used to release resources.
Please check this link

doXxx() is called from service() depending og the request type.Please read the API Doc for HttpServlet.
Rajendra Prakash
Ranch Hand

Joined: Sep 10, 2009
Posts: 293
If multiple request goes to servlet( service method ) means, it will be assigned to thread.
I asked two requests are there , which one will be processed first.
you said thread pool (And queue) decides which thread to execute.
Is thread pool is the only way or can i set priority for the threads.
 
wood burning stoves
 
subject: Servlet Lifecycle