📄 servletcontext.html
字号:
getServlets</H3><PRE>public java.util.Enumeration <B>getServlets</B>()</PRE><DL><DD><B>Deprecated.</B> <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> <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 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 exception, java.lang.String msg)</PRE><DL><DD><B>Deprecated.</B> <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 message, java.lang.Throwable 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 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 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 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 name, java.lang.Object 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 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 ID="NavBarFont1"><B>Overview</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT ID="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 ID="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../deprecated-list.html"><FONT ID="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../index-all.html"><FONT ID="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../help-doc.html"><FONT ID="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/ServletConfig.html"><B>PREV CLASS</B></A> <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> <A HREF="ServletContext.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: INNER | 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><!-- =========== END OF NAVBAR =========== --><HR></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -