All Packages Class Hierarchy This Package Previous Next Index
Class javax.servlet.http.HttpServlet
java.lang.Object
|
+----javax.servlet.GenericServlet
|
+----javax.servlet.http.HttpServlet
- public abstract class HttpServlet
- extends GenericServlet
- implements Serializable
The mother-of-all-HttpServlets.
Every normal http servlet extends this class and overrides either the doGet
or doPost methods (or both).
The server calls service. Service in its turn calls doGet, doPost, whatever,
depending on the client's request.
- Version:
- Servlet API 2.0
-
HttpServlet()
- Does nothing
-
doDelete(HttpServletRequest, HttpServletResponse)
- This method is called on a "DELETE" request.
-
doGet(HttpServletRequest, HttpServletResponse)
- This method is called on a "GET" request.
-
doOptions(HttpServletRequest, HttpServletResponse)
- This method is called on a "OPTIONS" request.
-
doPost(HttpServletRequest, HttpServletResponse)
- This method is called on a "POST" request.
-
doPut(HttpServletRequest, HttpServletResponse)
- This method is called on a "PUT" request.
-
doTrace(HttpServletRequest, HttpServletResponse)
- This method is called on a "TRACE" request.
-
getLastModified(HttpServletRequest)
- Returns the time the requested uri was last modified in seconds since
1 january 1970.
-
service(HttpServletRequest, HttpServletResponse)
- This method looks whether the request is a POST, GET, etc method,
and then calls the appropriate doPost, doGet, whatever method.
If the request method is something it can't handle it sends
a HttpServletResponse.SC_BAD_REQUEST error through the response.
-
service(ServletRequest, ServletResponse)
- Frontend for calling service(HttpServletRequest,HttpServletResponse).
HttpServlet
public HttpServlet()
- Does nothing
doDelete
protected void doDelete(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException
- This method is called on a "DELETE" request.
The default implementation is that
HttpServletResponse.SC_BAD_REQUEST (error nr: 400)
and the message "Method \"DELETE\" is not supported by this servlet"
is returned to the client.
- Throws: ServletException
- if an Servlet Exception occurs
- Throws: IOException
- if an IOException occurs
doGet
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException
- This method is called on a "GET" request.
The default implementation is that
HttpServletResponse.SC_BAD_REQUEST (error nr: 400)
and the message "Method \"GET\" is not supported by this servlet"
is returned to the client.
- Throws: ServletException
- if an Servlet Exception occurs
- Throws: IOException
- if an IOException occurs
doOptions
protected void doOptions(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException
- This method is called on a "OPTIONS" request.
It tells the client which methods are supported by the servlet.
This comes down to an implementation where HEAD, TRACE and OPTIONS
are supported by default because this class contains default
implementations of them. GET, POST, DELETE and PUT are added
to this list if the subclass has its own implementation of
the doGet, doPost, doDelete or doPut method respectively.
Note:
This implementation is probably not the most efficient one,
but the whole OPTIONS thing is intended for debugging
purposes, and this implementation does the job.
- Throws: ServletException
- if an Servlet Exception occurs
- Throws: IOException
- if an IOException occurs
doPost
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException
- This method is called on a "POST" request.
The default implementation is that
HttpServletResponse.SC_BAD_REQUEST (error nr: 400)
and the message "Method \"POST\" is not supported by this servlet"
is returned to the client.
- Throws: ServletException
- if an Servlet Exception occurs
- Throws: IOException
- if an IOException occurs
doPut
protected void doPut(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException
- This method is called on a "PUT" request.
The default implementation is that
HttpServletResponse.SC_BAD_REQUEST (error nr: 400)
and the message "Method \"PUT\" is not supported by this servlet"
is returned to the client.
- Throws: ServletException
- if an Servlet Exception occurs
- Throws: IOException
- if an IOException occurs
doTrace
protected void doTrace(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException
- This method is called on a "TRACE" request.
This method is for debugging purposes.
When a client makes a TRACE request the following is returned:
content type = "message/http"
message size: <size of the complete message>
first line of the message : TRACE <requested uri>
<protocol>
on the following lines all the request header names and values
- Throws: ServletException
- if an Servlet Exception occurs
- Throws: IOException
- if an IOException occurs
getLastModified
protected long getLastModified(HttpServletRequest request)
- Returns the time the requested uri was last modified in seconds since
1 january 1970. Default implementation returns -1.
service
protected void service(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException
- This method looks whether the request is a POST, GET, etc method,
and then calls the appropriate doPost, doGet, whatever method.
If the request method is something it can't handle it sends
a HttpServletResponse.SC_BAD_REQUEST error through the response.
- Throws: ServletException
- an error has occured
- Throws: IOException
- an error has occured
service
public void service(ServletRequest request,
ServletResponse response) throws ServletException, IOException
- Frontend for calling service(HttpServletRequest,HttpServletResponse).
This method tries to typecast the ServletRequest and the
ServletResponse to HttpServletRequest and HttpServletResponse
and then call service(HttpServletRequest,HttpServletResponse).
- Parameters:
- request - The client's request
- response - The class to write the response date to.
- Throws: ServletException
- an error has occured
- Throws: IOException
- an error has occured
- Overrides:
- service in class GenericServlet
All Packages Class Hierarchy This Package Previous Next Index