Servlet interface provides commonbehaviorto all the servlets.Servlet interface defines methods that all servlets must implement.
Servlet interface needs to be implemented for creating any servlet (either directly or indirectly). It provides 3 life cycle methods that are used to initialize the servlet, to service the requests, and to destroy the servlet and 2 non-life cycle methods.
Methods of Servlet interface
There are 5 methods in Servlet interface. The init, service and destroy are the life cycle methods of servlet. These are invoked by the web container.
Servlet Example by implementing Servlet interface
Let's see the simple example of servlet by implementing the servlet interface.
It will be better if you learn it after visiting steps to create a servlet.
Next TopicGenericServlet Class