Name
Servlet
Synopsis
Interface Name:
javax.servlet.Servlet
Superinterface: None
Immediate Subinterfaces: None
Implemented By: javax.servlet.GenericServlet
Availability: Servlet API 1.0 and later
Description
All servlets implement the Servlet
interface,
either directly or by subclassing the
GenericServlet
or HttpServlet
class. Most servlet developers find it easier to subclass one of the
two existing servlet classes than to implement this interface
directly. The interface declares the basic servlet
functionalityâinitializing a servlet, handling a client
request, and destroying a servlet.
Interface Declaration
public interface Servlet { // Methods public abstract void destroy(); public abstract ServletConfig getServletConfig(); public abstract String getServletInfo(); public abstract void init(ServletConfig config) throws ServletException; public abstract void service(ServletRequest req, ServletResponse res) throws ServletException, IOException; }
Methods
destroy()
public abstract void destroy()
- Description
Called by the servlet container to indicate to a servlet that the servlet has been taken out of service. See the full description under
GenericServlet
.
getServletConfig()
public abstract ServletConfig getServletConfig()
- Description
Returns the
ServletConfig
object saved by theinit( )
method.
getServletInfo()
public abstract String getServletInfo()
- Description
Returns a programmer-defined
String
that describes the servlet.
init()
public abstract void init(ServletConfig config) throws ServletException ...
Get Java Servlet Programming, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.