aspose 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
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Overridding service() method!??