|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.servlet.GenericServlet
javax.servlet.http.HttpServlet
public abstract class HttpServlet
HttpServlet is a convenient abstract class for creating servlets.
Normally, servlet writers will only need to override
doGet
or doPost
.
getLastModified
. As long as the page hasn't changed,
it can avoid the overhead of any heavy processing or database queries.
You cannot use getLastModified
if the response depends
on sessions, cookies, or any headers in the servlet request.
package test;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class Hello extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("Hello, World");
out.close();
}
}
Constructor Summary | |
---|---|
HttpServlet()
|
Method Summary | |
---|---|
protected void |
doDelete(HttpServletRequest req,
HttpServletResponse res)
Process a DELETE request |
protected void |
doGet(HttpServletRequest req,
HttpServletResponse res)
Process a GET or HEAD request |
protected void |
doHead(HttpServletRequest req,
HttpServletResponse res)
Process a HEAD request. |
protected void |
doOptions(HttpServletRequest req,
HttpServletResponse res)
Process an OPTIONS request |
protected void |
doPost(HttpServletRequest req,
HttpServletResponse res)
Process a POST request |
protected void |
doPut(HttpServletRequest req,
HttpServletResponse res)
Process a PUT request |
protected void |
doTrace(HttpServletRequest req,
HttpServletResponse res)
Process a TRACE request |
protected long |
getLastModified(HttpServletRequest req)
Returns the last-modified time for the page for caching. |
protected void |
service(HttpServletRequest req,
HttpServletResponse res)
Services a HTTP request. |
void |
service(ServletRequest request,
ServletResponse response)
Service a request. |
Methods inherited from class javax.servlet.GenericServlet |
---|
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, init, log, log, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public HttpServlet()
Method Detail |
---|
public void service(ServletRequest request, ServletResponse response) throws ServletException, java.io.IOException
service
in interface Servlet
request
- request information. Normally servlets will cast this
to HttpServletRequest
response
- response information. Normally servlets will cast this
to HttpServletRequest
ServletException
java.io.IOException
protected void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, java.io.IOException
req
- request informationres
- response object for returning data to the client.
ServletException
java.io.IOException
protected long getLastModified(HttpServletRequest req)
getLastModified
to improve performance. Servlet engines like Resin can
cache the results of the page, resulting in near-static performance.
req
- the request
protected void doHead(HttpServletRequest req, HttpServletResponse res) throws ServletException, java.io.IOException
req
- the client requestres
- response to the client
ServletException
java.io.IOException
protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, java.io.IOException
req
- the client requestres
- response to the client
ServletException
java.io.IOException
protected void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, java.io.IOException
req
- the client requestres
- response to the client
ServletException
java.io.IOException
protected void doPut(HttpServletRequest req, HttpServletResponse res) throws ServletException, java.io.IOException
req
- the client requestres
- response to the client
ServletException
java.io.IOException
protected void doDelete(HttpServletRequest req, HttpServletResponse res) throws ServletException, java.io.IOException
req
- the client requestres
- response to the client
ServletException
java.io.IOException
protected void doOptions(HttpServletRequest req, HttpServletResponse res) throws ServletException, java.io.IOException
req
- the client requestres
- response to the client
ServletException
java.io.IOException
protected void doTrace(HttpServletRequest req, HttpServletResponse res) throws ServletException, java.io.IOException
req
- the client requestres
- response to the client
ServletException
java.io.IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |