This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Overridding service() method!??

 
Niyas Ahmed Sheikh
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic