Why is the Service() method in the servlet not overriden?
Thanks
Tim Moores
Rancher
Joined: Sep 21, 2011
Posts: 2407
posted
0
This question doesn't make sense without seeing the piece of code you're talking about. Any particular servlet may or may not override that method (note that's called "service", not "Service"). It's true that almost all servlets do not need to override it, though. I noticed a writeup of this exact question at http://www.coderanch.com/how-to/java/ServletsFaq#overriding-service
Haina Minawa
Ranch Hand
Joined: Oct 13, 2011
Posts: 119
posted
0
Akhilesh Murthy wrote:Why is the Service() method in the servlet not overriden?
Thanks
I think your question should be changed to "Why should not override servlet's service() method?"
Well, the default implementation of the service() method parses the HTTP method (GET, POST, PUT...) and calls the appropriate methods (doGet(), doPost(), doPut() ...) accordingly. If you override the service() method and do not handle all the HTTP methods correctly, there are chances that some kind of requests would not be served.