HttpServlet is an Abstract class with all the methods that are concrete.
HttpServlet is derived from GenericServlet which is also an abstract class.
HttpServlet has two service() methods one public that is inherited from GenericServlet class that takes (ServletRequest,SetvletResponse)and the other protected service method that overloads the previous method and has
(HttpServletRequest,HttpServletResponse) as parameters.
Now the typical call to the servlet is:
The container calls the public service method ...
the service method internally typecasts the ServletRequest to HttpServletRequest and same with response and calls the protected service
method .
The protected service method then internally verifies if it is GET or POST
and promptly calls doGet() or doPost().
My problem is why doesn't the public service method do the job that the
protected method is doing??...when it already has HttpServletRequest and
HttpServletResponse and also it can call getMethod() method.
HttpServlet is derived from GenericServlet which is also an abstract class.
HttpServlet has two service() methods one public that is inherited from GenericServlet class that takes (ServletRequest,SetvletResponse)and the other protected service method that overloads the previous method and has
(HttpServletRequest,HttpServletResponse) as parameters.
Now the typical call to the servlet is:
The container calls the public service method ...
the service method internally typecasts the ServletRequest to HttpServletRequest and same with response and calls the protected service
method .
The protected service method then internally verifies if it is GET or POST
and promptly calls doGet() or doPost().
My problem is why doesn't the public service method do the job that the
protected method is doing??...when it already has HttpServletRequest and
HttpServletResponse and also it can call getMethod() method.