• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Why is the Service() method in the servlet not overriden?

 
Ranch Hand
Posts: 31
1
Oracle Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why is the Service() method in the servlet not overriden?

Thanks
 
Saloon Keeper
Posts: 7582
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 https://coderanch.com/how-to/java/ServletsFaq#overriding-service
 
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Cob is sand, clay and sometimes straw. This tiny ad is made of cob:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic