René Nyffenegger's collection of things on the web
René Nyffenegger on Oracle - Most wanted - Feedback -
 

Servlet interface

All servlets must implement the javax.servlet.Servlet interface. There are two classes in the Servlet API that already implement this interface: GenericServlet and HttpServlet (the latter of which derives from the first).
In most cases, it is easier to inherit from these two classes than to implement the Servlet interface.

Methods of the Servlet interface

service

This method, required by the Servlet interface, handles requests: it is called for each request that involves that particular servlet.
The method might be called again before the first method call is finished. So, concurrency issues must be observed.

init

init is called by the servlet container to provide a possibility to the servlet to initialize itself.
init is passed an object that implements the ServletConfig interface that can be used to read the web applications's configuration file.

destroy

getServletInfo

GenericServlet

getInitParameter()

java.lang.String getInitParameter(java.lang.String name) 
This method returnes the named (name) initialization parameter, if it exists, or null, otherwise.

getInitParamterNames()

getServletConfig()

getServletContext()

getServletInfo()

getServletName()

init()

log()

service()

HttpServlet

HttpServlet derives from GenericServlet and adds the following methods:
which represent the various HTTP methods.
Additionally, there's a getLastModified method.