📄 servlet.html
字号:
<!-- ========= CONSTRUCTOR DETAIL ======== --><!-- ============ METHOD DETAIL ========== --><A NAME="method_detail"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""><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" title="interface in javax.servlet">ServletConfig</A> config) throws <A HREF="../../javax/servlet/ServletException.html" title="class in javax.servlet">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><P><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" title="class in javax.servlet">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" title="class in javax.servlet"><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" title="interface in javax.servlet">ServletConfig</A> <B>getServletConfig</B>()</PRE><DL><DD>Returns a <A HREF="../../javax/servlet/ServletConfig.html" title="interface in javax.servlet"><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" title="class in javax.servlet"><CODE>GenericServlet</CODE></A> class, which implements this interface, already does this.<P><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" title="interface in javax.servlet">ServletRequest</A> req, <A HREF="../../javax/servlet/ServletResponse.html" title="interface in javax.servlet">ServletResponse</A> res) throws <A HREF="../../javax/servlet/ServletException.html" title="class in javax.servlet">ServletException</A>, <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/io/IOException.html" title="class or interface in java.io">IOException</A></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>.<P><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" title="class in javax.servlet">ServletException</A></CODE> - if an exception occurs that interferes with the servlet's normal operation<DD><CODE><A HREF="http://java.sun.com/j2se/1.4/docs/api/java/io/IOException.html" title="class or interface in java.io">IOException</A></CODE> - if an input or output exception occurs</DL></DD></DL><HR><A NAME="getServletInfo()"><!-- --></A><H3>getServletInfo</H3><PRE>public <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> <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.).<P><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.<P><DD><DL></DL></DD></DL><!-- ========= END OF CLASS DATA ========= --><HR><!-- ======= START OF BOTTOM NAVBAR ====== --><A NAME="navbar_bottom"><!-- --></A><A HREF="#skip-navbar_bottom" 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_bottom_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="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><b>Java<sup><font size=-2>TM</font></sup> 2 Platform<br>Ent. Ed. v1.4</b></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../javax/servlet/RequestDispatcher.html" title="interface in javax.servlet"><B>PREV CLASS</B></A> <A HREF="../../javax/servlet/ServletConfig.html" title="interface in javax.servlet"><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="Servlet.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 | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: FIELD | CONSTR | <A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><A NAME="skip-navbar_bottom"></A><!-- ======== END OF BOTTOM NAVBAR ======= --><HR><font size="-1"><a href="http://java.sun.com/webapps/bugreport">Submit a bug or feature</a> <p>Copyright 2003 Sun Microsystems, Inc. All rights reserved.</font></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -