Explain why HttpServlet is declared abstract.- The Constructor HttpServlet() does nothing because this is an abstract class.
- Default implementation 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:
1. doGet: - If the servlet supports HTTP GET requests.
2.doPost: - HTTP POST requests. 3. doPut: - HTTP PUT requests. 4. doDelete: - HTTP DELETE requests. 5. init() and destroy(): - To manage resources. 6. 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.What is the GenericServlet class?- GenericServlet makes writing servlets easier.
- To write a generic servlet, all you need to do is to override the abstract service method.
|