Name
Servlet
Synopsis
Interface Name: javax.servlet.Servlet
Super-interface: 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 when the server is preparing to unload a servlet. Used to clean up any outstanding resources (database connections, threads, file handles and so forth). The servlet programmer is responsible for making sure that any requests currently executing are allowed to finish.
getServletConfig()
public abstract ServletConfig getServletConfig()
- Description
Returns the
ServletConfig
object passed to theinit()
method.
getServletInfo()
public abstract String getServletInfo()
- Description
Returns a programmer-defined ...
Get Java Servlet Programming 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.