Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Service Method

 
Prabhu Chandrasekaran
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sandhya,
Thanks for your reply.
I will post any more doubts that I have in this forum.
Bye.

------------------
 
indyahack
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic