aspose file tools
The moose likes Servlets and the fly likes Why only doGet()  or doPost() & not service Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "Why only doGet()  or doPost() & not service" Watch "Why only doGet()  or doPost() & not service" New topic
Author

Why only doGet() or doPost() & not service

Syed Khateeb
Greenhorn

Joined: Sep 30, 2006
Posts: 7
Why is it advised to override doGet()&/doPost() instead directly overriding service()?
Is it only because the possibility of having implementations for for other doXyz() methods is not possible?
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6592
    
    1

You can override other doXXX methods as well. Most of the time you can accomplish what you want the servlet to do using the doGet and doPost methods.


SCJP 6 articles - SCJP 5/6 mock exams - SCJP Mocks - SCJP 5 Mock exam (Word document ) - SCJP 5 Mock exam in Java.Inquisition format
Chetan Raju
Ranch Hand

Joined: Aug 02, 2006
Posts: 109
By Overriding service() method, you need to implement logic to read the type of HTTP request (GET/POST). But, currently the service method already does this and dispatches the request to doPost()/doGet() method appropriately.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why only doGet() or doPost() & not service
 
Similar Threads
When a request is sent to the servlet
why we should not override service() method in a servlet
Why Not Overload Service Method.
Differences Between doGet(),doPost(),service()
Multi-threading in servlets