aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes what is called? service method or doGet method? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "what is called? service method or doGet method? " Watch "what is called? service method or doGet method? " New topic
Author

what is called? service method or doGet method?

Ankur Jain Kothari
Ranch Hand

Joined: Feb 08, 2010
Posts: 154
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?


Do What You Wanna Be....Taking Things The Way They Come
scjp 1.6 91 percent, scmad 90 percent(rounded off to nearest integer)
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41885
    
  63
The service method does indeed call the doGet method for a GET request. What is "the program" that led you to believe otherwise?


Ping & DNS - my free Android networking tools app
Ankur Jain Kothari
Ranch Hand

Joined: Feb 08, 2010
Posts: 154
Ankur Jain Kothari
Ranch Hand

Joined: Feb 08, 2010
Posts: 154
ok sorry..wrong service method used..


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

Thanks
Ankur Jain Kothari
Ranch Hand

Joined: Feb 08, 2010
Posts: 154
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

Joined: Feb 08, 2010
Posts: 154
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

Joined: Jan 13, 2010
Posts: 78
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
Marshal

Joined: Mar 22, 2005
Posts: 41885
    
  63
... which is why using the @Override annotation can be a life-saver :-)
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: what is called? service method or doGet method?