• 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 the service methods in HttpServlet abstract class are protected?

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why the service methods in HttpServlet abstract class are protected? While all the other methods in all classes and interfaces are public. Can anybody explain indetail.
protected void doGet(HttpServletRequest req, HttpServletRespone res)
protected void doPost(HttpServletRequest req, HttpServletRespone res)
protected void doTrace(HttpServletRequest req, HttpServletRespone )
protected void doOptions(HttpServletRequest req, HttpServletRespone res)
protected void doPut(HttpServletRequest req, HttpServletRespone res)
protected void service(HttpServletRequest req, HttpServletRespone res)
public void service(Servletrequest req, ServletResponse res)
Thanks in advance
Suresh K
 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Because those methods should NEVER be called directly by anything other than the service method. The web container will call the public serivce which will then decide what to do with the request. Making the service methods protected enforces this.
If you want logic in doGet/doPost that is available outside of a container generated call, move it into an other object instead of a servlet.
reply
    Bookmark Topic Watch Topic
  • New Topic