Ques : What is HttpServlet Class

, , No Comments

The javax.servlet.http package contains a number of classes and interfaces that are used to create HTTP protocol-specific Servlets. The abstract class HttpServlet is a base class for user defined HTTP Servlets which provide methods. The basic methods such as doGet and doPost are for handling HTTP-specific services. When you are developing your own servlets then you can use HttpServlet class which is extended from GenericServlet.

public abstract class HttpServlet

Unlike with GenericServlet, when you extend HttpServlet, you can skip implement
ing the service() method. The HttpServlet class has already implemented the service()
method. The following are the prototype of the service() method:

protected void service(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException

When the HttpServlet.service() method is invoked, it first reads the method type
stored in the request, and on that basis it determines the method to be invoked. For
example if the method type is GET, it will call doGet() method, and if the method
type is POST, it will call doPost() method. These methods have the same parameter as
the service() method.

There are many interfaces in javax.servlet.http package but the three important
interfaces HttpServletRequest, HttpServletResponse and HttpSession are described
below:

0 टिप्पणियाँ:

Post a Comment