servletcontext.html

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

HTML
935
字号
getServlets</H3>
<PRE>
public java.util.Enumeration <B>getServlets</B>()</PRE>
<DL>
<DD><B>Deprecated.</B>&nbsp;<I>As of Java Servlet API 2.0, with no replacement.

 <p>This method was originally defined to return an <code>Enumeration</code>
 of all the servlets known to this servlet context. In this
 version, this method always returns an empty enumeration and
 remains only to preserve binary compatibility. This method
 will be permanently removed in a future version of the Java
 Servlet API.</I>
<P>
</DL>
<HR>

<A NAME="getServletNames()"><!-- --></A><H3>
getServletNames</H3>
<PRE>
public java.util.Enumeration <B>getServletNames</B>()</PRE>
<DL>
<DD><B>Deprecated.</B>&nbsp;<I>As of Java Servlet API 2.1, with no replacement.

 <p>This method was originally defined to return an 
 <code>Enumeration</code>
 of all the servlet names known to this context. In this version,
 this method always returns an empty <code>Enumeration</code> and 
 remains only to preserve binary compatibility. This method will 
 be permanently removed in a future version of the Java Servlet API.</I>
<P>
</DL>
<HR>

<A NAME="log(java.lang.String)"><!-- --></A><H3>
log</H3>
<PRE>
public void <B>log</B>(java.lang.String&nbsp;msg)</PRE>
<DL>
<DD>Writes the specified message to a servlet log file, usually
 an event log. The name and type of the servlet log file is 
 specific to the servlet container.<DD><DL>
<DT><B>Parameters:</B><DD><CODE>msg</CODE> - a <code>String</code> specifying the 
			message to be written to the log file</DL>
</DD>
</DL>
<HR>

<A NAME="log(java.lang.Exception, java.lang.String)"><!-- --></A><H3>
log</H3>
<PRE>
public void <B>log</B>(java.lang.Exception&nbsp;exception,
                java.lang.String&nbsp;msg)</PRE>
<DL>
<DD><B>Deprecated.</B>&nbsp;<I>As of Java Servlet API 2.1, use
 			<A HREF="../../javax/servlet/ServletContext.html#log(java.lang.String, java.lang.Throwable)"><CODE>log(String message, Throwable throwable)</CODE></A> 
			instead.

 <p>This method was originally defined to write an 
 exception's stack trace and an explanatory error message
 to the servlet log file.</I>
<P>
</DL>
<HR>

<A NAME="log(java.lang.String, java.lang.Throwable)"><!-- --></A><H3>
log</H3>
<PRE>
public void <B>log</B>(java.lang.String&nbsp;message,
                java.lang.Throwable&nbsp;throwable)</PRE>
<DL>
<DD>Writes an explanatory message and a stack trace
 for a given <code>Throwable</code> exception
 to the servlet log file. The name and type of the servlet log 
 file is specific to the servlet container, usually an event log.<DD><DL>
<DT><B>Parameters:</B><DD><CODE>message</CODE> - a <code>String</code> that 
				describes the error or exception<DD><CODE>throwable</CODE> - the <code>Throwable</code> error 
				or exception</DL>
</DD>
</DL>
<HR>

<A NAME="getRealPath(java.lang.String)"><!-- --></A><H3>
getRealPath</H3>
<PRE>
public java.lang.String <B>getRealPath</B>(java.lang.String&nbsp;path)</PRE>
<DL>
<DD>Returns a <code>String</code> containing the real path 
 for a given virtual path. For example, the path "/index.html"
 returns the absolute file path on the server's filesystem would be
 served by a request for "http://host/contextPath/index.html",
 where contextPath is the context path of this ServletContext..

 <p>The real path returned will be in a form
 appropriate to the computer and operating system on
 which the servlet container is running, including the
 proper path separators. This method returns <code>null</code>
 if the servlet container cannot translate the virtual path
 to a real path for any reason (such as when the content is
 being made available from a <code>.war</code> archive).<DD><DL>
<DT><B>Parameters:</B><DD><CODE>path</CODE> - a <code>String</code> specifying a virtual path<DT><B>Returns:</B><DD>a <code>String</code> specifying the real path,
                  or null if the translation cannot be performed</DL>
</DD>
</DL>
<HR>

<A NAME="getServerInfo()"><!-- --></A><H3>
getServerInfo</H3>
<PRE>
public java.lang.String <B>getServerInfo</B>()</PRE>
<DL>
<DD>Returns the name and version of the servlet container on which
 the servlet is running. 

 <p>The form of the returned string is 
 <i>servername</i>/<i>versionnumber</i>.
 For example, the JavaServer Web Development Kit may return the string
 <code>JavaServer Web Dev Kit/1.0</code>.

 <p>The servlet container may return other optional information 
 after the primary string in parentheses, for example,
 <code>JavaServer Web Dev Kit/1.0 (JDK 1.1.6; Windows NT 4.0 x86)</code>.<DD><DL>
<DT><B>Returns:</B><DD>a <code>String</code> containing at least the 
			servlet container name and version number</DL>
</DD>
</DL>
<HR>

<A NAME="getInitParameter(java.lang.String)"><!-- --></A><H3>
getInitParameter</H3>
<PRE>
public java.lang.String <B>getInitParameter</B>(java.lang.String&nbsp;name)</PRE>
<DL>
<DD>Returns a <code>String</code> containing the value of the named
 context-wide initialization parameter, or <code>null</code> if the 
 parameter does not exist.

 <p>This method can make available configuration information useful
 to an entire "web application".  For example, it can provide a 
 webmaster's email address or the name of a system that holds 
 critical data.<DD><DL>
<DT><B>Parameters:</B><DD><CODE>name</CODE> - a <code>String</code> containing the name of the
                  parameter whose value is requested<DT><B>Returns:</B><DD>a <code>String</code> containing at least the 
			servlet container name and version number<DT><B>See Also: </B><DD><A HREF="../../javax/servlet/ServletConfig.html#getInitParameter(java.lang.String)"><CODE>ServletConfig.getInitParameter(java.lang.String)</CODE></A></DL>
</DD>
</DL>
<HR>

<A NAME="getInitParameterNames()"><!-- --></A><H3>
getInitParameterNames</H3>
<PRE>
public java.util.Enumeration <B>getInitParameterNames</B>()</PRE>
<DL>
<DD>Returns the names of the context's initialization parameters as an
 <code>Enumeration</code> of <code>String</code> objects, or an
 empty <code>Enumeration</code> if the context has no initialization
 parameters.<DD><DL>
<DT><B>Returns:</B><DD>an <code>Enumeration</code> of <code>String</code> 
                  objects containing the names of the context's
                  initialization parameters<DT><B>See Also: </B><DD><A HREF="../../javax/servlet/ServletConfig.html#getInitParameter(java.lang.String)"><CODE>ServletConfig.getInitParameter(java.lang.String)</CODE></A></DL>
</DD>
</DL>
<HR>

<A NAME="getAttribute(java.lang.String)"><!-- --></A><H3>
getAttribute</H3>
<PRE>
public java.lang.Object <B>getAttribute</B>(java.lang.String&nbsp;name)</PRE>
<DL>
<DD>Returns the servlet container attribute with the given name, 
 or <code>null</code> if there is no attribute by that name.
 An attribute allows a servlet container to give the
 servlet additional information not
 already provided by this interface. See your
 server documentation for information about its attributes.
 A list of supported attributes can be retrieved using
 <code>getAttributeNames</code>.

 <p>The attribute is returned as a <code>java.lang.Object</code>
 or some subclass.
 Attribute names should follow the same convention as package
 names. The Java Servlet API specification reserves names
 matching <code>java.*</code>, <code>javax.*</code>,
 and <code>sun.*</code>.<DD><DL>
<DT><B>Parameters:</B><DD><CODE>name</CODE> - a <code>String</code> specifying the name 
			of the attribute<DT><B>Returns:</B><DD>an <code>Object</code> containing the value 
			of the attribute, or <code>null</code>
			if no attribute exists matching the given
			name<DT><B>See Also: </B><DD><A HREF="../../javax/servlet/ServletContext.html#getAttributeNames()"><CODE>getAttributeNames()</CODE></A></DL>
</DD>
</DL>
<HR>

<A NAME="getAttributeNames()"><!-- --></A><H3>
getAttributeNames</H3>
<PRE>
public java.util.Enumeration <B>getAttributeNames</B>()</PRE>
<DL>
<DD>Returns an <code>Enumeration</code> containing the 
 attribute names available
 within this servlet context. Use the
 <A HREF="../../javax/servlet/ServletContext.html#getAttribute(java.lang.String)"><CODE>getAttribute(java.lang.String)</CODE></A> method with an attribute name
 to get the value of an attribute.<DD><DL>
<DT><B>Returns:</B><DD>an <code>Enumeration</code> of attribute 
			names<DT><B>See Also: </B><DD><A HREF="../../javax/servlet/ServletContext.html#getAttribute(java.lang.String)"><CODE>getAttribute(java.lang.String)</CODE></A></DL>
</DD>
</DL>
<HR>

<A NAME="setAttribute(java.lang.String, java.lang.Object)"><!-- --></A><H3>
setAttribute</H3>
<PRE>
public void <B>setAttribute</B>(java.lang.String&nbsp;name,
                         java.lang.Object&nbsp;object)</PRE>
<DL>
<DD>Binds an object to a given attribute name in this servlet context. If
 the name specified is already used for an attribute, this
 method will replace the attribute with the new to the new attribute.
 <p>If listeners are configured on the <code>ServletContext</code> the  
 container notifies them accordingly.
 <p>
 If a null value is passed, the effect is the same as calling 
 <code>removeAttribute()</code>.
 
 <p>Attribute names should follow the same convention as package
 names. The Java Servlet API specification reserves names
 matching <code>java.*</code>, <code>javax.*</code>, and
 <code>sun.*</code>.<DD><DL>
<DT><B>Parameters:</B><DD><CODE>name</CODE> - a <code>String</code> specifying the name 
			of the attribute<DD><CODE>object</CODE> - an <code>Object</code> representing the
			attribute to be bound</DL>
</DD>
</DL>
<HR>

<A NAME="removeAttribute(java.lang.String)"><!-- --></A><H3>
removeAttribute</H3>
<PRE>
public void <B>removeAttribute</B>(java.lang.String&nbsp;name)</PRE>
<DL>
<DD>Removes the attribute with the given name from 
 the servlet context. After removal, subsequent calls to
 <A HREF="../../javax/servlet/ServletContext.html#getAttribute(java.lang.String)"><CODE>getAttribute(java.lang.String)</CODE></A> to retrieve the attribute's value
 will return <code>null</code>.

 <p>If listeners are configured on the <code>ServletContext</code> the 
 container notifies them accordingly.<DD><DL>
<DT><B>Parameters:</B><DD><CODE>name</CODE> - a <code>String</code> specifying the name 
 			of the attribute to be removed</DL>
</DD>
</DL>
<HR>

<A NAME="getServletContextName()"><!-- --></A><H3>
getServletContextName</H3>
<PRE>
public java.lang.String <B>getServletContextName</B>()</PRE>
<DL>
<DD>Returns the name of this web application correponding to this ServletContext as specified in the deployment
 descriptor for this web application by the display-name element.<DD><DL>
<DT><B>Returns:</B><DD>The name of the web application or null if no name has been declared in the deployment descriptor.<DT><B>Since: </B><DD>Servlet 2.3</DD>
</DL>
</DD>
</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/ServletConfig.html"><B>PREV CLASS</B></A>&nbsp;
&nbsp;<A HREF="../../javax/servlet/ServletContextAttributeListener.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="ServletContext.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 + -
显示快捷键?