public interface Servlet
Servlets handle server request.
Servlets have 5 phases in their lifespan, as follows:
init
method
somewhere between creation and the first request it ever gives
the servlet to handle.
service
method.
The server packages all the request data in a ServletRequest object, and
creates a ServletResponse object for the servlet to write reply data to.Modifier and Type | Method and Description |
---|---|
void |
destroy()
Called by the server when it no longer needs the servlet.
|
ServletConfig |
getServletConfig()
Gets the servlet config class.
|
java.lang.String |
getServletInfo()
Gets a string containing information about the servlet.
|
void |
init(ServletConfig config)
Initializes the servlet.
|
void |
service(ServletRequest request,
ServletResponse response)
Called by the server every time it wants the servlet to handle
a request.
|
void init(ServletConfig config) throws ServletException
ServletConfig
so it can return it again when the
getConfig()
method is called. If the the servlet is
temporarily or permanently unavailable it should throw an
UnavailableException
.config
- This servlet configuration classServletException
- If an unexpected error occursUnavailableException
- If servlet is temporarily or permanently
unavailableUnavailableException
ServletConfig getServletConfig()
ServletConfig
that was handed to the init()
method.void service(ServletRequest request, ServletResponse response) throws java.io.IOException, ServletException
SingleThreadModel
interface.request
- all the request informationresponse
- class to write all the response data toServletException
- If an error occursjava.io.IOException
- If an error occursSingleThreadModel
java.lang.String getServletInfo()
void destroy()