If you are trying to create a servlet program of your own ,the two main class for servlet implementation are-
- GenericServlet—For all general purpose servlet capable of handling any protocol.
- HttpServlet— HttpServlet is a extended class from GenericServlet , handles only HTTP protocol.
The two types of object a service method accepts are
- Request–the information directing to the servlet
- Response–The information towards server viz client
well this is bit advanced process. when ever you are extending to HttpServlet, the service() method is written there.so we need to invoke that method. HttpServlet.service().
The best part of this when the service method is called,it determines the request and which methods to be called.Say we have the method type is GET then doGet() method is called or else if we have post as request method then corresponding doPost() method is called.
Note: All these methods can be overridden.
The other methods inside a HttpServlet’s service method are-