What is the difference between GenericServlet and HTTPServlet?

GenericServlet is an abstract class that defines a generic, protocol-independent servlet.Any protocol dependent servlet has to extend this class in order to provide a specific implementaion and override service method.e.g . HTTPServlet class extends GenericServlet class.
GenericServlet has a service(ServletRequest req, ServletResponse res) method which is called by the servlet container to allow the servlet to respond to a request.
HttpServlet extends GenericServlet and adds support for doGet(), doPost(), doHead() methods (HTTP 1.0) plus doPut(), doOptions(), doDelete(), doTrace() methods (HTTP 1.1). Both these classes are abstract.


Vivek said...

Good One this blog has lot of information

solanki on June 8, 2011 at 12:39 AM said...

gud one answer, i get different and well define from others blogs.

solanki on June 8, 2011 at 12:39 AM said...

i got well described answer from others blogs.

Unknown on February 9, 2018 at 8:05 AM said...

it is too good if you mentioned about HttpServletRequest and HttpServletResponse are arguments as in doGet(HttpServletRequest request , HttpServletResponse response);
doPost(HttpServletRequest request , HttpServletResponse response);


Interview Questions On Java,Java EE Copyright © 2018. Reads: best tracker