This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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: 41068
    
  43
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: 70
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: 41068
    
  43
... which is why using the @Override annotation can be a life-saver :-)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: what is called? service method or doGet method?
 
Similar Threads
please reply urgently!!!
Can we Have Write Service,doGet,doPost method implementation in a single servlet
Overridding service() method!??
When a request is sent to the servlet
Http Request Type in Servlet