httpservlet.html

来自「SUN公司官方J2EE中文帮助文档 应该不错 有兴趣的下来看看 html格式的」· HTML 代码 · 共 746 行 · 第 1/3 页

HTML
746
字号
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd">
<!--NewPage-->
<HTML>
<HEAD>
<!-- Generated by javadoc on Thu Jan 17 03:51:38 PST 2002 -->
<TITLE>
Java 2 Platform EE v1.3: Class  HttpServlet
</TITLE>
<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style">
</HEAD>
<BODY BGCOLOR="white">

<!-- ========== START OF NAVBAR ========== -->
<A NAME="navbar_top"><!-- --></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_top_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3">
  <TR ALIGN="center" VALIGN="top">
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
  </TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>

<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
&nbsp;<A HREF="../../../javax/servlet/http/Cookie.html"><B>PREV CLASS</B></A>&nbsp;
&nbsp;<A HREF="../../../javax/servlet/http/HttpServletRequestWrapper.html"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
  <A HREF="../../../index.html" TARGET="_top"><B>FRAMES</B></A>  &nbsp;
&nbsp;<A HREF="HttpServlet.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
  SUMMARY: &nbsp;INNER&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL: &nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<!-- =========== END OF NAVBAR =========== -->

<HR>
<!-- ======== START OF CLASS DATA ======== -->
<H2>
<FONT SIZE="-1">
javax.servlet.http</FONT>
<BR>
Class  HttpServlet</H2>
<PRE>
java.lang.Object
  |
  +--<A HREF="../../../javax/servlet/GenericServlet.html">javax.servlet.GenericServlet</A>
        |
        +--<B>javax.servlet.http.HttpServlet</B>
</PRE>
<DL>
<DT><B>All Implemented Interfaces:</B> <DD>java.io.Serializable, <A HREF="../../../javax/servlet/Servlet.html">Servlet</A>, <A HREF="../../../javax/servlet/ServletConfig.html">ServletConfig</A></DD>
</DL>
<HR>
<DL>
<DT>public abstract class <B>HttpServlet</B><DT>extends <A HREF="../../../javax/servlet/GenericServlet.html">GenericServlet</A><DT>implements java.io.Serializable</DL>

<P>
Provides an abstract class to be subclassed to create
 an HTTP servlet suitable for a Web site. A subclass of
 <code>HttpServlet</code> must override at least 
 one method, usually one of these:

 <ul>
 <li> <code>doGet</code>, if the servlet supports HTTP GET requests
 <li> <code>doPost</code>, for HTTP POST requests
 <li> <code>doPut</code>, for HTTP PUT requests
 <li> <code>doDelete</code>, for HTTP DELETE requests
 <li> <code>init</code> and <code>destroy</code>, 
 to manage resources that are held for the life of the servlet
 <li> <code>getServletInfo</code>, which the servlet uses to
 provide information about itself 
 </ul>

 <p>There's almost no reason to override the <code>service</code>
 method. <code>service</code> handles standard HTTP
 requests by dispatching them to the handler methods
 for each HTTP request type (the <code>do</code><i>XXX</i>
 methods listed above).

 <p>Likewise, there's almost no reason to override the 
 <code>doOptions</code> and <code>doTrace</code> methods.
 
 <p>Servlets typically run on multithreaded servers,
 so be aware that a servlet must handle concurrent
 requests and be careful to synchronize access to shared resources.
 Shared resources include in-memory data such as
 instance or class variables and external objects
 such as files, database connections, and network 
 connections.
 See the
 <a href="http://java.sun.com/Series/Tutorial/java/threads/multithreaded.html">
 Java Tutorial on Multithreaded Programming</a> for more
 information on handling multiple threads in a Java program.
<P>
<DL>
<DT><B>See Also: </B><DD><A HREF="../../../serialized-form.html#javax.servlet.http.HttpServlet">Serialized Form</A></DL>
<HR>

<P>
<!-- ======== INNER CLASS SUMMARY ======== -->


<!-- =========== FIELD SUMMARY =========== -->


<!-- ======== CONSTRUCTOR SUMMARY ======== -->

<A NAME="constructor_summary"><!-- --></A>
<TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=2><FONT SIZE="+2">
<B>Constructor Summary</B></FONT></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE><B><A HREF="../../../javax/servlet/http/HttpServlet.html#HttpServlet()">HttpServlet</A></B>()</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Does nothing, because this is an abstract class.</TD>
</TR>
</TABLE>
&nbsp;
<!-- ========== METHOD SUMMARY =========== -->

<A NAME="method_summary"><!-- --></A>
<TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=2><FONT SIZE="+2">
<B>Method Summary</B></FONT></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>protected &nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../javax/servlet/http/HttpServlet.html#doDelete(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)">doDelete</A></B>(<A HREF="../../../javax/servlet/http/HttpServletRequest.html">HttpServletRequest</A>&nbsp;req,
         <A HREF="../../../javax/servlet/http/HttpServletResponse.html">HttpServletResponse</A>&nbsp;resp)</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Called by the server (via the <code>service</code> method)
 to allow a servlet to handle a DELETE request.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>protected &nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../javax/servlet/http/HttpServlet.html#doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)">doGet</A></B>(<A HREF="../../../javax/servlet/http/HttpServletRequest.html">HttpServletRequest</A>&nbsp;req,
      <A HREF="../../../javax/servlet/http/HttpServletResponse.html">HttpServletResponse</A>&nbsp;resp)</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Called by the server (via the <code>service</code> method) to
 allow a servlet to handle a GET request.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>protected &nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../javax/servlet/http/HttpServlet.html#doHead(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)">doHead</A></B>(<A HREF="../../../javax/servlet/http/HttpServletRequest.html">HttpServletRequest</A>&nbsp;req,
       <A HREF="../../../javax/servlet/http/HttpServletResponse.html">HttpServletResponse</A>&nbsp;resp)</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Receives an HTTP HEAD request from the protected
 <code>service</code> method and handles the
 request.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>protected &nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../javax/servlet/http/HttpServlet.html#doOptions(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)">doOptions</A></B>(<A HREF="../../../javax/servlet/http/HttpServletRequest.html">HttpServletRequest</A>&nbsp;req,
          <A HREF="../../../javax/servlet/http/HttpServletResponse.html">HttpServletResponse</A>&nbsp;resp)</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Called by the server (via the <code>service</code> method)
 to allow a servlet to handle a OPTIONS request.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>protected &nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../javax/servlet/http/HttpServlet.html#doPost(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)">doPost</A></B>(<A HREF="../../../javax/servlet/http/HttpServletRequest.html">HttpServletRequest</A>&nbsp;req,
       <A HREF="../../../javax/servlet/http/HttpServletResponse.html">HttpServletResponse</A>&nbsp;resp)</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Called by the server (via the <code>service</code> method)
 to allow a servlet to handle a POST request.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>protected &nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../javax/servlet/http/HttpServlet.html#doPut(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)">doPut</A></B>(<A HREF="../../../javax/servlet/http/HttpServletRequest.html">HttpServletRequest</A>&nbsp;req,
      <A HREF="../../../javax/servlet/http/HttpServletResponse.html">HttpServletResponse</A>&nbsp;resp)</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Called by the server (via the <code>service</code> method)
 to allow a servlet to handle a PUT request.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>protected &nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../javax/servlet/http/HttpServlet.html#doTrace(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)">doTrace</A></B>(<A HREF="../../../javax/servlet/http/HttpServletRequest.html">HttpServletRequest</A>&nbsp;req,
        <A HREF="../../../javax/servlet/http/HttpServletResponse.html">HttpServletResponse</A>&nbsp;resp)</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Called by the server (via the <code>service</code> method)
 to allow a servlet to handle a TRACE request.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>protected &nbsp;long</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../javax/servlet/http/HttpServlet.html#getLastModified(javax.servlet.http.HttpServletRequest)">getLastModified</A></B>(<A HREF="../../../javax/servlet/http/HttpServletRequest.html">HttpServletRequest</A>&nbsp;req)</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the time the <code>HttpServletRequest</code>
 object was last modified,
 in milliseconds since midnight January 1, 1970 GMT.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>protected &nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../javax/servlet/http/HttpServlet.html#service(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)">service</A></B>(<A HREF="../../../javax/servlet/http/HttpServletRequest.html">HttpServletRequest</A>&nbsp;req,
        <A HREF="../../../javax/servlet/http/HttpServletResponse.html">HttpServletResponse</A>&nbsp;resp)</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Receives standard HTTP requests from the public
 <code>service</code> method and dispatches
 them to the <code>do</code><i>XXX</i> methods defined in 
 this class.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../javax/servlet/http/HttpServlet.html#service(javax.servlet.ServletRequest, javax.servlet.ServletResponse)">service</A></B>(<A HREF="../../../javax/servlet/ServletRequest.html">ServletRequest</A>&nbsp;req,
        <A HREF="../../../javax/servlet/ServletResponse.html">ServletResponse</A>&nbsp;res)</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dispatches client requests to the protected
 <code>service</code> method.</TD>
</TR>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?