1.

Explain Why Httpservlet Is Declared Abstract.

Answer»

The Constructor HttpServlet() does nothing because this is an ABSTRACT class. DEFAULT implementations in a few JAVA classes like HttpServlet don’t really do anything. Hence, they need to be overridden.

Usually one of the following methods of HttpServlet must be overridden by a subclass:

doGet, if the servlet supports HTTP GET requests
doPost, HTTP POST requests
doPut, HTTP PUT requests
doDelete, HTTP DELETE requests
init and destroy, to manage resources
getServletInfo, to provide information

HOWEVER, there doesn’t seem to be any reason why the SERVICE method should be overridden because it eventually dispatches the task to one of the doXXX methods.

The Constructor HttpServlet() does nothing because this is an abstract class. Default implementations in a few Java classes like HttpServlet don’t really do anything. Hence, they need to be overridden.

Usually one of the following methods of HttpServlet must be overridden by a subclass:

However, there doesn’t seem to be any reason why the service method should be overridden because it eventually dispatches the task to one of the doXXX methods.



Discussion

No Comment Found