| Author |
Why the service methods in HttpServlet abstract class are protected?
|
Suresh Khanna
Greenhorn
Joined: Jan 04, 2004
Posts: 16
|
|
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
|
 |
Ken Robinson
Ranch Hand
Joined: Dec 23, 2003
Posts: 101
|
|
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.
|
 |
 |
|
|
subject: Why the service methods in HttpServlet abstract class are protected?
|
|
|