About Servlet Interface

Servlet used for dynamic web development and Two package belong to it are following:
javax.​servlet
javax.servlet.http
Defines methods that all servlets must implement.

A servlet is an Interface and a small Java program that runs within a Web server. Servlets receive and respond to requests from Web clients, usually across HTTP(HyperText Transfer Protocol).


To implement this interface, you can write a generic servlet that extends javax.servlet.GenericServlet or HTTP servlet that extends javax.servlet.http.HttpServlet.

This interface defines methods to initialize a servlet, to service requests, and to remove a servlet from the server. These are known as life-cycle methods and are called in the following sequence:

1.The servlet is constructed, then initialized with the init method.
2. Any calls from clients to the service method are handled.
3.The servlet is taken out of service, then destroyed with the destroy method, then garbage collected and finalized.

In addition to the life-cycle methods, this interface provides the getServletConfig method, which the servlet can use to get any startup information, and the getServletInfo method, which allows the servlet to return basic information about itself, such as author, version, and copyright.
More Servlet Topics :

No comments: