?? servletcontext.html
字號:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd"><!--NewPage--><HTML><HEAD><!-- Generated by javadoc on Mon Sep 29 15:11:53 PDT 2003 --><TITLE>: Interface ServletContext</TITLE><LINK REL ="stylesheet" TYPE="text/css" HREF="../../stylesheet.css" TITLE="Style"></HEAD><BODY BGCOLOR="white"><!-- ========== START OF NAVBAR ========== --><A NAME="navbar_top"><!-- --></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_top_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><!-- ======== START OF CLASS DATA ======== --><H2><FONT SIZE="-1">javax.servlet</FONT><BR>Interface ServletContext</H2><HR><DL><DT>public interface <B>ServletContext</B></DL><P>Defines a set of methods that a servlet uses to communicate with its servlet container, for example, to get the MIME type of a file, dispatch requests, or write to a log file. <p>There is one context per "web application" per Java Virtual Machine. (A "web application" is a collection of servlets and content installed under a specific subset of the server's URL namespace such as <code>/catalog</code> and possibly installed via a <code>.war</code> file.) <p>In the case of a web application marked "distributed" in its deployment descriptor, there will be one context instance for each virtual machine. In this situation, the context cannot be used as a location to share global information (because the information won't be truly global). Use an external resource like a database instead. <p>The <code>ServletContext</code> object is contained within the <A HREF="../../javax/servlet/ServletConfig.html"><CODE>ServletConfig</CODE></A> object, which the Web server provides the servlet when the servlet is initialized.<P><DL><DT><B>See Also: </B><DD><A HREF="../../javax/servlet/Servlet.html#getServletConfig()"><CODE>Servlet.getServletConfig()</CODE></A>, <A HREF="../../javax/servlet/ServletConfig.html#getServletContext()"><CODE>ServletConfig.getServletContext()</CODE></A></DL><HR><P><!-- ======== INNER CLASS SUMMARY ======== --><!-- =========== FIELD SUMMARY =========== --><!-- ======== CONSTRUCTOR SUMMARY ======== --><!-- ========== METHOD SUMMARY =========== --><A NAME="method_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Method Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> java.lang.Object</CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/servlet/ServletContext.html#getAttribute(java.lang.String)">getAttribute</A></B>(java.lang.String name)</CODE><BR> Returns the servlet container attribute with the given name, or <code>null</code> if there is no attribute by that name.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> java.util.Enumeration</CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/servlet/ServletContext.html#getAttributeNames()">getAttributeNames</A></B>()</CODE><BR> Returns an <code>Enumeration</code> containing the attribute names available within this servlet context.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../../javax/servlet/ServletContext.html">ServletContext</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/servlet/ServletContext.html#getContext(java.lang.String)">getContext</A></B>(java.lang.String uripath)</CODE><BR> Returns a <code>ServletContext</code> object that corresponds to a specified URL on the server.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> java.lang.String</CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/servlet/ServletContext.html#getInitParameter(java.lang.String)">getInitParameter</A></B>(java.lang.String name)</CODE><BR> 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.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> java.util.Enumeration</CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/servlet/ServletContext.html#getInitParameterNames()">getInitParameterNames</A></B>()</CODE><BR> 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.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> int</CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/servlet/ServletContext.html#getMajorVersion()">getMajorVersion</A></B>()</CODE><BR> Returns the major version of the Java Servlet API that this servlet container supports.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> java.lang.String</CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/servlet/ServletContext.html#getMimeType(java.lang.String)">getMimeType</A></B>(java.lang.String file)</CODE><BR> Returns the MIME type of the specified file, or <code>null</code> if the MIME type is not known.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> int</CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/servlet/ServletContext.html#getMinorVersion()">getMinorVersion</A></B>()</CODE><BR> Returns the minor version of the Servlet API that this servlet container supports.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../../javax/servlet/RequestDispatcher.html">RequestDispatcher</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/servlet/ServletContext.html#getNamedDispatcher(java.lang.String)">getNamedDispatcher</A></B>(java.lang.String name)</CODE><BR> Returns a <A HREF="../../javax/servlet/RequestDispatcher.html"><CODE>RequestDispatcher</CODE></A> object that acts as a wrapper for the named servlet.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> java.lang.String</CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/servlet/ServletContext.html#getRealPath(java.lang.String)">getRealPath</A></B>(java.lang.String path)</CODE><BR> Returns a <code>String</code> containing the real path for a given virtual path.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../../javax/servlet/RequestDispatcher.html">RequestDispatcher</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/servlet/ServletContext.html#getRequestDispatcher(java.lang.String)">getRequestDispatcher</A></B>(java.lang.String path)</CODE><BR> Returns a <A HREF="../../javax/servlet/RequestDispatcher.html"><CODE>RequestDispatcher</CODE></A> object that acts as a wrapper for the resource located at the given path.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> java.net.URL</CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/servlet/ServletContext.html#getResource(java.lang.String)">getResource</A></B>(java.lang.String path)</CODE><BR> Returns a URL to the resource that is mapped to a specified path.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> java.io.InputStream</CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/servlet/ServletContext.html#getResourceAsStream(java.lang.String)">getResourceAsStream</A></B>(java.lang.String path)</CODE><BR> Returns the resource located at the named path as an <code>InputStream</code> object.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> java.util.Set</CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/servlet/ServletContext.html#getResourcePaths(java.lang.String)">getResourcePaths</A></B>(java.lang.String path)</CODE><BR> Returns a directory-like listing of all the paths to resources within the web application whose longest sub-path matches the supplied path argument.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> java.lang.String</CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/servlet/ServletContext.html#getServerInfo()">getServerInfo</A></B>()</CODE><BR> Returns the name and version of the servlet container on which the servlet is running.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../../javax/servlet/Servlet.html">Servlet</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/servlet/ServletContext.html#getServlet(java.lang.String)">getServlet</A></B>(java.lang.String name)</CODE><BR> <B>Deprecated.</B> <I>As of Java Servlet API 2.1, with no direct replacement. <p>This method was originally defined to retrieve a servlet from a <code>ServletContext</code>. In this version, this method always returns <code>null</code> and remains only to preserve binary compatibility. This method will be permanently removed in a future version of the Java Servlet API. <p>In lieu of this method, servlets can share information using the <code>ServletContext</code> class and can perform shared business logic by invoking methods on common non-servlet classes.</I></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> java.lang.String</CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/servlet/ServletContext.html#getServletContextName()">getServletContextName</A></B>()</CODE><BR> 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.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> java.util.Enumeration</CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/servlet/ServletContext.html#getServletNames()">getServletNames</A></B>()</CODE><BR> <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></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> java.util.Enumeration</CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/servlet/ServletContext.html#getServlets()">getServlets</A></B>()</CODE><BR> <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></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> void</CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/servlet/ServletContext.html#log(java.lang.Exception, java.lang.String)">log</A></B>(java.lang.Exception exception, java.lang.String msg)</CODE><BR> <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.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -