Can you explain why servlets extend HttpServlet?- Most of the web applications uses HTTP protocol. The user requests need to be received and processed through the HTTP protocol.
- Hence, the servlets should extend HttpServlet and override the doGet() and / or doPost() methods, depending on the data that is sent by GET or by POST.
- The HttpServlet simplifies the handling of the HTTP protocol but its not a compulsion to extend the servlet class must extend the abstract HttpServlet class.
- The GenericServlet class can be extended to make the servlet protocol independent.
|