📄 httpservlet.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--NewPage-->
<HTML>
<HEAD>
<!-- Generated by javadoc (build 1.4.2_09) on Fri Sep 23 09:41:10 EDT 2005 -->
<TITLE>
HttpServlet (Servlet API Documentation)
</TITLE>
<META NAME="keywords" CONTENT="javax.servlet.http.HttpServlet class">
<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style">
<SCRIPT type="text/javascript">
function windowTitle()
{
parent.document.title="HttpServlet (Servlet API Documentation)";
}
</SCRIPT>
</HEAD>
<BODY BGCOLOR="white" onload="windowTitle();">
<!-- ========= START OF TOP NAVBAR ======= -->
<A NAME="navbar_top"><!-- --></A>
<A HREF="#skip-navbar_top" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=3 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_top_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/HttpServlet.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../javax/servlet/http/Cookie.html" title="class in javax.servlet.http"><B>PREV CLASS</B></A>
<A HREF="../../../javax/servlet/http/HttpServletRequestWrapper.html" title="class in javax.servlet.http"><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>
<A HREF="HttpServlet.html" target="_top"><B>NO FRAMES</B></A>
<SCRIPT type="text/javascript">
<!--
if(window==top) {
document.writeln('<A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A>');
}
//-->
</SCRIPT>
<NOSCRIPT>
<A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>
</FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
SUMMARY: NESTED | FIELD | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL: FIELD | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_top"></A>
<!-- ========= END OF TOP NAVBAR ========= -->
<HR>
<!-- ======== START OF CLASS DATA ======== -->
<H2>
<FONT SIZE="-1">
javax.servlet.http</FONT>
<BR>
Class HttpServlet</H2>
<PRE>
java.lang.Object
<IMG SRC="../../../resources/inherit.gif" ALT="extended by"><A HREF="../../../javax/servlet/GenericServlet.html" title="class in javax.servlet">javax.servlet.GenericServlet</A>
<IMG SRC="../../../resources/inherit.gif" ALT="extended by"><B>javax.servlet.http.HttpServlet</B>
</PRE>
<DL>
<DT><B>All Implemented Interfaces:</B> <DD>java.io.Serializable, <A HREF="../../../javax/servlet/Servlet.html" title="interface in javax.servlet">Servlet</A>, <A HREF="../../../javax/servlet/ServletConfig.html" title="interface in javax.servlet">ServletConfig</A></DD>
</DL>
<HR>
<DL>
<DT>public abstract class <B>HttpServlet</B><DT>extends <A HREF="../../../javax/servlet/GenericServlet.html" title="class in javax.servlet">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>
<P>
<DL>
<DT><B>Version:</B></DT>
<DD>$Version$</DD>
<DT><B>Author:</B></DT>
<DD>Various</DD>
<DT><B>See Also:</B><DD><A HREF="../../../serialized-form.html#javax.servlet.http.HttpServlet">Serialized Form</A></DL>
<HR>
<P>
<!-- ======== NESTED CLASS SUMMARY ======== -->
<!-- =========== FIELD SUMMARY =========== -->
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<A NAME="constructor_summary"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<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>
Does nothing, because this is an abstract class.</TD>
</TR>
</TABLE>
<!-- ========== METHOD SUMMARY =========== -->
<A NAME="method_summary"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<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 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" title="interface in javax.servlet.http">HttpServletRequest</A> req,
<A HREF="../../../javax/servlet/http/HttpServletResponse.html" title="interface in javax.servlet.http">HttpServletResponse</A> resp)</CODE>
<BR>
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 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" title="interface in javax.servlet.http">HttpServletRequest</A> req,
<A HREF="../../../javax/servlet/http/HttpServletResponse.html" title="interface in javax.servlet.http">HttpServletResponse</A> resp)</CODE>
<BR>
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 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" title="interface in javax.servlet.http">HttpServletRequest</A> req,
<A HREF="../../../javax/servlet/http/HttpServletResponse.html" title="interface in javax.servlet.http">HttpServletResponse</A> resp)</CODE>
<BR>
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 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" title="interface in javax.servlet.http">HttpServletRequest</A> req,
<A HREF="../../../javax/servlet/http/HttpServletResponse.html" title="interface in javax.servlet.http">HttpServletResponse</A> resp)</CODE>
<BR>
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 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" title="interface in javax.servlet.http">HttpServletRequest</A> req,
<A HREF="../../../javax/servlet/http/HttpServletResponse.html" title="interface in javax.servlet.http">HttpServletResponse</A> resp)</CODE>
<BR>
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 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" title="interface in javax.servlet.http">HttpServletRequest</A> req,
<A HREF="../../../javax/servlet/http/HttpServletResponse.html" title="interface in javax.servlet.http">HttpServletResponse</A> resp)</CODE>
<BR>
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 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" title="interface in javax.servlet.http">HttpServletRequest</A> req,
<A HREF="../../../javax/servlet/http/HttpServletResponse.html" title="interface in javax.servlet.http">HttpServletResponse</A> resp)</CODE>
<BR>
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 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" title="interface in javax.servlet.http">HttpServletRequest</A> req)</CODE>
<BR>
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 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" title="interface in javax.servlet.http">HttpServletRequest</A> req,
<A HREF="../../../javax/servlet/http/HttpServletResponse.html" title="interface in javax.servlet.http">HttpServletResponse</A> resp)</CODE>
<BR>
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> 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" title="interface in javax.servlet">ServletRequest</A> req,
<A HREF="../../../javax/servlet/ServletResponse.html" title="interface in javax.servlet">ServletResponse</A> res)</CODE>
<BR>
Dispatches client requests to the protected
<code>service</code> method.</TD>
</TR>
</TABLE>
<A NAME="methods_inherited_from_class_javax.servlet.GenericServlet"><!-- --></A>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -