File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Service Method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Service Method" Watch "Service Method" New topic
Author

Service Method

Prabhu Chandrasekaran
Ranch Hand

Joined: Oct 14, 2000
Posts: 36
Friends,
I have a basic doubt in service method implementation in servlets.
Does the service method in a servlet get executed every time a servlet is called?
Can you give me the life cycle of a servlet which comprises of an init(), service(), doGet(), doPost() and destroy() ?

Advance Thanks...
------------------
sandhya Jahagirdar
Greenhorn

Joined: Oct 19, 2000
Posts: 2
hi,
init will be called once when servlet first time called.
the service() method will invoke every time the request will be made to the servlet and it recognizes the header which has information about the methods to be invoked (put,get,post etc) and then it dispatches to the doXXX methods.
whatever I know I told.
regards
sandhya
Prabhu Chandrasekaran
Ranch Hand

Joined: Oct 14, 2000
Posts: 36
Hi Sandhya,
Thanks for your reply.
I will post any more doubts that I have in this forum.
Bye.

------------------
indyahack
Greenhorn

Joined: Oct 24, 2000
Posts: 7
HI,
here's the servlet life cycle
1) create and initialize the servlet. here it calls the init method only once the servlet is loaded in the memory, i.e when the servlet engine starts.
2) handle zero or more service calls, i.e. handle all the clients calls . every client request creates one thread, the servlet creates one thread for each doget() and dopost() methods.
3) destory the servlet and garbage collect it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Service Method