If we put some request, intially either doget() or dopost() is getting invoked? why not any servlet life cycle method is not getting invoked?Then why don't we include this doget() and dopost() in the servlet life cycle methods?

Questions by Roshini

Showing Answers 1 - 13 of 13 Answers

C.R.Venkatesh

  • Aug 27th, 2006
 

If I understand your question, doPost/doGet is part of servlet's life-cycle only but is implied. Meaning, service() method plays the actual role of calling respective request methods (doGet/doPost) upon inspecting HTTP header. To brief, init/service/destroy are the life-cycle methods and doGet/doPost/doDelete are the methods called by service. HTH.

  Was this answer useful?  Yes

ramana

  • Aug 31st, 2006
 

If u send any request to the servlet then container calls generic servlet service() method first.Ttis is implemented method in HttpServlet.The default implemented code in this method is calling of HttpServlet Service().In this default implementaton code is checking code.Means it checks the incoming request contains get methos then calls doGet().If it contains post then it calls doPost().If incoming request doesnot contain any method by default it calls doGet().

  Was this answer useful?  Yes

spoorthi

  • Sep 13th, 2006
 

  First Generic Servlet service method invokes the req, res objects and after that it converts req, res into httpservletreq, httpservletres objects then it invokes doGet(), or doPost() methods

  Was this answer useful?  Yes

Vasuneet Arya

  • Sep 20th, 2006
 

Dear,

doGet and doPost are not the part of Servlet Life Cycle directly. But indirectly if devloper have not been override service method of Servlet ,they are parting in servlet life cycle because these method would be called by Service method of HtttpServlet.

Life cycle of Servlet

Init()/Service()/destroy()

and service mehtod calls doPost or doGet method according to Http Header information.

  Was this answer useful?  Yes

Neha

  • Nov 18th, 2007
 

If we put some request initially....the server call's the HttpServlet's service method where by seeing the request type service method call either doGet( if request is get) or doPost (if request is Post).... so all is done by service method and its included in servlet's life cycle.

  Was this answer useful?  Yes

sampra

  • Mar 4th, 2008
 

If I understand your question, doPost/doGet is part of servlet's life-cycle only but is implied. Meaning, service() method plays the actual role of calling respective request methods (doGet/doPost) upon inspecting HTTP header. To brief, init/service/destroy are the life-cycle methods and doGet/doPost/doDelete are the methods called by service.

  Was this answer useful?  Yes

sampra

  • Mar 6th, 2008
 

If I understand your question, doPost/doGet is part of servlet's life-cycle only but is implied. Meaning, service() method plays the actual role of calling respective request methods (doGet/doPost) upon inspecting HTTP header. To brief, init/service/destroy are the life-cycle methods and doGet/doPost/doDelete are the methods called by service. HTH.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions