📄 servletcontext.html
字号:
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).
<P>
<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>.
<P>
<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.
<P>
<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.
<P>
<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>.
<P>
<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.
<P>
<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>.
<P>
<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.
<P>
<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 corresponding to this ServletContext as specified in the deployment
descriptor for this web application by the display-name element.
<P>
<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></DT>
<DD>Servlet 2.3</DD>
</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="class-use/ServletContext.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/ServletConfig.html" title="interface in javax.servlet"><B>PREV CLASS</B></A>
<A HREF="../../javax/servlet/ServletContextAttributeListener.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="ServletContext.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>
Copyright © 1999-2002 The Apache Software Foundation. All Rights Reserved.
</BODY>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -