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() ?
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
Joined: Oct 14, 2000
Hi Sandhya, Thanks for your reply. I will post any more doubts that I have in this forum. Bye.
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.