⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 servletcontext.html

📁 j2ee帮助文档软件设计/软件工程 文件格式
💻 HTML
📖 第 1 页 / 共 4 页
字号:
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;<A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/servlet/ServletContext.html#getServerInfo()">getServerInfo</A></B>()</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;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>&nbsp;<A HREF="../../javax/servlet/Servlet.html" title="interface in javax.servlet">Servlet</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/servlet/ServletContext.html#getServlet(java.lang.String)">getServlet</A></B>(<A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A>&nbsp;name)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<B>Deprecated.</B>&nbsp;<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>&nbsp;<A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/servlet/ServletContext.html#getServletContextName()">getServletContextName</A></B>()</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;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>&nbsp;<A HREF="http://java.sun.com/j2se/1.5/docs/api/java/util/Enumeration.html" title="class or interface in java.util">Enumeration</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/servlet/ServletContext.html#getServletNames()">getServletNames</A></B>()</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<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></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;<A HREF="http://java.sun.com/j2se/1.5/docs/api/java/util/Enumeration.html" title="class or interface in java.util">Enumeration</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/servlet/ServletContext.html#getServlets()">getServlets</A></B>()</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<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></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;void</CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/servlet/ServletContext.html#log(java.lang.Exception, java.lang.String)">log</A></B>(<A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/Exception.html" title="class or interface in java.lang">Exception</A>&nbsp;exception,    <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A>&nbsp;msg)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<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></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;void</CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/servlet/ServletContext.html#log(java.lang.String)">log</A></B>(<A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A>&nbsp;msg)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Writes the specified message to a servlet log file, usually an event log.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;void</CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/servlet/ServletContext.html#log(java.lang.String, java.lang.Throwable)">log</A></B>(<A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A>&nbsp;message,    <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/Throwable.html" title="class or interface in java.lang">Throwable</A>&nbsp;throwable)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Writes an explanatory message and a stack trace for a given <code>Throwable</code> exception to the servlet log file.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;void</CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/servlet/ServletContext.html#removeAttribute(java.lang.String)">removeAttribute</A></B>(<A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A>&nbsp;name)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Removes the attribute with the given name from  the servlet context.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;void</CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/servlet/ServletContext.html#setAttribute(java.lang.String, java.lang.Object)">setAttribute</A></B>(<A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A>&nbsp;name,             <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/Object.html" title="class or interface in java.lang">Object</A>&nbsp;object)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Binds an object to a given attribute name in this servlet context.</TD></TR></TABLE>&nbsp;<P><!-- ============ METHOD DETAIL ========== --><A NAME="method_detail"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2"><B>Method Detail</B></FONT></TH></TR></TABLE><A NAME="getContextPath()"><!-- --></A><H3>getContextPath</H3><PRE><A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> <B>getContextPath</B>()</PRE><DL><DD>Returns the context path of the web application. <p>The context path is the portion of the request URI that is used to select the context of the request. The context path always comes first in a request URI. The path starts with a "/" character but does not end with a "/" character. For servlets in the default (root) context, this method returns "". <p>It is possible that a servlet container may match a context by more than one context path. In such cases the <A HREF="../../javax/servlet/http/HttpServletRequest.html#getContextPath()"><CODE>HttpServletRequest.getContextPath()</CODE></A> will return the actual context path used by the request and it may differ from the path returned by this method. The context path returned by this method should be considered as the prime or preferred context path of the application.<P><DD><DL><DT><B>Returns:</B><DD>The context path of the web application, or "" for the default (root) context<DT><B>Since:</B></DT>  <DD>Servlet 2.5</DD><DT><B>See Also:</B><DD><A HREF="../../javax/servlet/http/HttpServletRequest.html#getContextPath()"><CODE>HttpServletRequest.getContextPath()</CODE></A></DL></DD></DL><HR><A NAME="getContext(java.lang.String)"><!-- --></A><H3>getContext</H3><PRE><A HREF="../../javax/servlet/ServletContext.html" title="interface in javax.servlet">ServletContext</A> <B>getContext</B>(<A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A>&nbsp;uripath)</PRE><DL><DD>Returns a <code>ServletContext</code> object that  corresponds to a specified URL on the server. <p>This method allows servlets to gain access to the context for various parts of the server, and as needed obtain <A HREF="../../javax/servlet/RequestDispatcher.html" title="interface in javax.servlet"><CODE>RequestDispatcher</CODE></A> objects from the context. The given path must be begin with "/", is interpreted relative  to the server's document root and is matched against the context roots of other web applications hosted on this container.  <p>In a security conscious environment, the servlet container may return <code>null</code> for a given URL.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>uripath</CODE> - a <code>String</code> specifying the context path of                        another web application in the container.<DT><B>Returns:</B><DD>the <code>ServletContext</code> object that                        corresponds to the named URL, or null if either                        none exists or the container wishes to restrict                         this access.<DT><B>See Also:</B><DD><A HREF="../../javax/servlet/RequestDispatcher.html" title="interface in javax.servlet"><CODE>RequestDispatcher</CODE></A></DL></DD></DL><HR><A NAME="getMajorVersion()"><!-- --></A><H3>getMajorVersion</H3><PRE>int <B>getMajorVersion</B>()</PRE><DL><DD>Returns the major version of the Java Servlet API that this servlet container supports. All implementations that comply with Version 2.5 must have this method return the integer 2.<P><DD><DL><DT><B>Returns:</B><DD>2</DL></DD></DL><HR><A NAME="getMinorVersion()"><!-- --></A><H3>getMinorVersion</H3><PRE>int <B>getMinorVersion</B>()</PRE><DL><DD>Returns the minor version of the Servlet API that this servlet container supports. All implementations that comply with Version 2.5 must have this method return the integer 5.<P><DD><DL><DT><B>Returns:</B><DD>5</DL></DD></DL><HR><A NAME="getMimeType(java.lang.String)"><!-- --></A><H3>getMimeType</H3><PRE><A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> <B>getMimeType</B>(<A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A>&nbsp;file)</PRE><DL><DD>Returns the MIME type of the specified file, or <code>null</code> if  the MIME type is not known. The MIME type is determined by the configuration of the servlet container, and may be specified in a web application deployment descriptor. Common MIME types are <code>"text/html"</code> and <code>"image/gif"</code>.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>file</CODE> - a <code>String</code> specifying the name                        of a file<DT><B>Returns:</B><DD>a <code>String</code> specifying the file's MIME type</DL></DD></DL><HR><A NAME="getResourcePaths(java.lang.String)"><!-- --></A><H3>getResourcePaths</H3><PRE><A HREF="http://java.sun.com/j2se/1.5/docs/api/java/util/Set.html" title="class or interface in java.util">Set</A> <B>getResourcePaths</B>(<A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A>&nbsp;path)</PRE><DL><DD>Returns a directory-like listing of all the paths to resources within the web application whose longest sub-path matches the supplied path argument. Paths indicating subdirectory paths end with a '/'. The returned paths are all  relative to the root of the web application and have a leading '/'. For example, for a web application  containing<br><br> /welcome.html<br> /catalog/index.html<br> /catalog/products.html<br> /catalog/offers/books.html<br> /catalog/offers/music.html<br> /customer/login.jsp<br> /WEB-INF/web.xml<br> /WEB-INF/classes/com.acme.OrderServlet.class,<br><br> getResourcePaths("/") returns {"/welcome.html", "/catalog/", "/customer/", "/WEB-INF/"}<br> getResourcePaths("/catalog/") returns {"/catalog/index.html", "/catalog/products.html", "/catalog/offers/"}.<br><P><DD><DL><DT><B>Parameters:</B><DD><CODE>path</CODE> - the partial path used to match the resources,                                which must start with a /<DT><B>Returns:</B><DD>a Set containing the directory listing, or null if there are no resources in the web application whose path begins with the supplied path.<DT><B>Since:</B></DT>  <DD>Servlet 2.3</DD>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -