File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Overridding service() method!?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Overridding service() method!??" Watch "Overridding service() method!??" New topic
Author

Overridding service() method!??

Niyas Ahmed Sheikh
Ranch Hand

Joined: Jun 15, 2005
Posts: 129
Hi,

I read in some book that overridding the service() is not a good idea. But I seen some codings in which service() method has been overridden.
I want to know when it is needed to override the service() method. If we are overridding the service() method, what about doGet() and doPost().?
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Assuming you are talking about the service method in an HttpServlet, then the answer is probably in the code where you've seen this happen. Basically all the service method does is delegates to the appropriate doXXX() method depending on the request. Since HTTP changes only very occasionally, it's very unlikely that you will need to alter its behaviour.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

I can't even remember why we did it that way now, but in the early pre-Struts, pre-filter days we had an abstract Front Controller-like class that did something like this:



Not quite the same though.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Overridding service() method!??
 
Similar Threads
Polymorphism and Method Signatures
doubt in overridding
Doubt -Polymorphism-Overloading vs Overridding as per Kathy Sierra SCJP 1.5 Book?
Why cann't we initialize servlets in constructor?
Overridding!!