Well, you do need to have the logic somewhere, because although GET and POST are often used interchangeably, that's not always the case. I wouldn't think that the overhead is big enough to worry about.
I wouldn't recommend overriding the service method.
The doPost and doGet methods handle the two most common request methods. When a browser submits a form the POST method is generally used. Most other types of hits use the GET method (hyperlinks, image tags, etc..).
A common way to support both request types from a single servlet method without overriding your service method is just to have one method call the other.
so that we can reduce the overhead involved in resolving which method of these two to invoke..
Don't be silly, that just involves ONE CALL to request.getMethod() which you would have to do anyway if you override service. [rant] DON'T DON'T DON'T get distracted with these bizarre optimization schemes that circulate as rumours. Stick to the standard servlet API and concentrate on making your code clear. Please realize that by the time your servlet code gets a request, a HUGE amount of work has already been done by the underlying socket code and servlet container to set up the request and response objects. Any CPU cycles saved by "clever" tricks will be invisible. [/rant]
I'm sure that all is true that the various experts have said about it not being worth overriding service() to seek some tiny performance gain.
However, I have found one time when overriding service() does seem worthwhile to me. I override it to add some custom debug trace. The overriding service() method does some trace, then super.service(), then some more trace. It's a lot easier to add that trace in this one place, than in all those doXXX() methods.
Hopefully, those experts would consider this OK...?
Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
If you know what you're doing, there's nothing wrong with overriding service. That's why it's there. In your case, you've extended it to add some functionality common to all the request methods and then called super() to insure that all the standard functionality is called. Just using it, instead of doGet or doPost, in hopes of getting a faster app is what the folks here were advising against. [ June 30, 2006: Message edited by: Ben Souther ]