GenericServlet and HTTPServlet

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.
Is possible to have a constructor for a servlet?
Yes, it is possible to have a constructor for a servlet. However, it is not practiced usually. The operations with the constructor...
Difference between an Applet and a Servlet
Servlet and Applet - Applets are applications designed to be transmitted over the network and executed by Java compatible web browsers...
Servlet HTTP Tunneling - Define HTTP Tunneling?
Servlet HTTP Tunneling - The solution is to have them encapsulated in http or https and sent as an HttpRequest. Thus, masking other protocols as http requests is called HTTP Tunneling...
Post your comment