servlet.html

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

HTML
352
字号

<!-- ============ METHOD DETAIL ========== -->

<A NAME="method_detail"><!-- --></A>
<TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=1><FONT SIZE="+2">
<B>Method Detail</B></FONT></TD>
</TR>
</TABLE>

<A NAME="init(javax.servlet.ServletConfig)"><!-- --></A><H3>
init</H3>
<PRE>
public void <B>init</B>(<A HREF="../../javax/servlet/ServletConfig.html">ServletConfig</A>&nbsp;config)
          throws <A HREF="../../javax/servlet/ServletException.html">ServletException</A></PRE>
<DL>
<DD>Called by the servlet container to indicate to a servlet that the 
 servlet is being placed into service.

 <p>The servlet container calls the <code>init</code>
 method exactly once after instantiating the servlet.
 The <code>init</code> method must complete successfully
 before the servlet can receive any requests.

 <p>The servlet container cannot place the servlet into service
 if the <code>init</code> method
 <ol>
 <li>Throws a <code>ServletException</code>
 <li>Does not return within a time period defined by the Web server
 </ol><DD><DL>
<DT><B>Parameters:</B><DD><CODE>config</CODE> - a <code>ServletConfig</code> object 
					containing the servlet's
 					configuration and initialization parameters<DT><B>Throws:</B><DD><CODE><A HREF="../../javax/servlet/ServletException.html">ServletException</A></CODE> - if an exception has occurred that
					interferes with the servlet's normal
					operation<DT><B>See Also: </B><DD><A HREF="../../javax/servlet/UnavailableException.html"><CODE>UnavailableException</CODE></A>, 
<A HREF="../../javax/servlet/Servlet.html#getServletConfig()"><CODE>getServletConfig()</CODE></A></DL>
</DD>
</DL>
<HR>

<A NAME="getServletConfig()"><!-- --></A><H3>
getServletConfig</H3>
<PRE>
public <A HREF="../../javax/servlet/ServletConfig.html">ServletConfig</A> <B>getServletConfig</B>()</PRE>
<DL>
<DD>Returns a <A HREF="../../javax/servlet/ServletConfig.html"><CODE>ServletConfig</CODE></A> object, which contains
 initialization and startup parameters for this servlet.
 The <code>ServletConfig</code> object returned is the one 
 passed to the <code>init</code> method. 

 <p>Implementations of this interface are responsible for storing the 
 <code>ServletConfig</code> object so that this 
 method can return it. The <A HREF="../../javax/servlet/GenericServlet.html"><CODE>GenericServlet</CODE></A>
 class, which implements this interface, already does this.<DD><DL>
<DT><B>Returns:</B><DD>the <code>ServletConfig</code> object
			that initializes this servlet<DT><B>See Also: </B><DD><A HREF="../../javax/servlet/Servlet.html#init(javax.servlet.ServletConfig)"><CODE>init(javax.servlet.ServletConfig)</CODE></A></DL>
</DD>
</DL>
<HR>

<A NAME="service(javax.servlet.ServletRequest, javax.servlet.ServletResponse)"><!-- --></A><H3>
service</H3>
<PRE>
public void <B>service</B>(<A HREF="../../javax/servlet/ServletRequest.html">ServletRequest</A>&nbsp;req,
                    <A HREF="../../javax/servlet/ServletResponse.html">ServletResponse</A>&nbsp;res)
             throws <A HREF="../../javax/servlet/ServletException.html">ServletException</A>,
                    java.io.IOException</PRE>
<DL>
<DD>Called by the servlet container to allow the servlet to respond to 
 a request.

 <p>This method is only called after the servlet's <code>init()</code>
 method has completed successfully.
 
 <p>  The status code of the response always should be set for a servlet 
 that throws or sends an error.

 
 <p>Servlets typically run inside multithreaded servlet containers
 that can handle multiple requests concurrently. Developers must 
 be aware to synchronize access to any shared resources such as files,
 network connections, and as well as the servlet's class and instance 
 variables. 
 More information on multithreaded programming in Java is available in 
 <a href="http://java.sun.com/Series/Tutorial/java/threads/multithreaded.html">
 the Java tutorial on multi-threaded programming</a>.<DD><DL>
<DT><B>Parameters:</B><DD><CODE>req</CODE> - the <code>ServletRequest</code> object that contains
			the client's request<DD><CODE>res</CODE> - the <code>ServletResponse</code> object that contains
			the servlet's response<DT><B>Throws:</B><DD><CODE><A HREF="../../javax/servlet/ServletException.html">ServletException</A></CODE> - if an exception occurs that interferes
					with the servlet's normal operation<DD><CODE>java.io.IOException</CODE> - if an input or output exception occurs</DL>
</DD>
</DL>
<HR>

<A NAME="getServletInfo()"><!-- --></A><H3>
getServletInfo</H3>
<PRE>
public java.lang.String <B>getServletInfo</B>()</PRE>
<DL>
<DD>Returns information about the servlet, such
 as author, version, and copyright.
 
 <p>The string that this method returns should
 be plain text and not markup of any kind (such as HTML, XML,
 etc.).<DD><DL>
<DT><B>Returns:</B><DD>a <code>String</code> containing servlet information</DL>
</DD>
</DL>
<HR>

<A NAME="destroy()"><!-- --></A><H3>
destroy</H3>
<PRE>
public void <B>destroy</B>()</PRE>
<DL>
<DD>Called by the servlet container to indicate to a servlet that the
 servlet is being taken out of service.  This method is
 only called once all threads within the servlet's
 <code>service</code> method have exited or after a timeout
 period has passed. After the servlet container calls this 
 method, it will not call the <code>service</code> method again
 on this servlet.

 <p>This method gives the servlet an opportunity 
 to clean up any resources that are being held (for example, memory,
 file handles, threads) and make sure that any persistent state is
 synchronized with the servlet's current state in memory.</DL>
<!-- ========= END OF CLASS DATA ========= -->
<HR>

<!-- ========== START OF NAVBAR ========== -->
<A NAME="navbar_bottom"><!-- --></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_bottom_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/RequestDispatcher.html"><B>PREV CLASS</B></A>&nbsp;
&nbsp;<A HREF="../../javax/servlet/ServletConfig.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="Servlet.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;CONSTR&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL: &nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<!-- =========== END OF NAVBAR =========== -->

<HR>

</BODY>
</HTML>

⌨️ 快捷键说明

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