• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what is called? service method or doGet method?

 
Ankur Jain Kothari
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When i read the book head first i thought that the service method calls the doGet method..but when i ran the program the service method never ran...why is it so?
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The service method does indeed call the doGet method for a GET request. What is "the program" that led you to believe otherwise?
 
Ankur Jain Kothari
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Ankur Jain Kothari
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok sorry..wrong service method used..


with this code the service method ran and then called doGet method

Thanks
 
Ankur Jain Kothari
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this is the text from hanumant deshmukh...is this right?
If you override the service methods in your servlet class, you will lose the
functionality provided by the HttpServlet class, and the doXXX()
methods will not be called automatically. In your implementation, you will
have to determine the HTTP method used in the request, and then you will
have to call the appropriate doXXX() method yourself. For this reason, it’s
recommended to only override the doPost() or doGet() methods.


but in the code of the earlier post doGet was called even though i didnt call doGet from service method....can anyone explain please
 
Ankur Jain Kothari
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am so confused..sometimes service calls doGet even though i didnt call doGet from it...and other times it does....something is wrong with my netbeans
 
Ravinderjit Singh
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you code service method like this in your servlet

then the method implemented by HttpServlet class will be called.

You can review the service method of this HttpServlet class; line number 607 here

If you code service method like this


then you need to call doXXX() explicitly.
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
... which is why using the @Override annotation can be a life-saver :-)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic