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

📄 servletcontext.html

📁 j2ee帮助文档软件设计/软件工程 文件格式
💻 HTML
📖 第 1 页 / 共 4 页
字号:
</DL></DD></DL><HR><A NAME="getResource(java.lang.String)"><!-- --></A><H3>getResource</H3><PRE><A HREF="http://java.sun.com/j2se/1.5/docs/api/java/net/URL.html" title="class or interface in java.net">URL</A> <B>getResource</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)                throws <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/net/MalformedURLException.html" title="class or interface in java.net">MalformedURLException</A></PRE><DL><DD>Returns a URL to the resource that is mapped to a specified path. The path must begin with a "/" and is interpreted as relative to the current context root. <p>This method allows the servlet container to make a resource  available to servlets from any source. Resources  can be located on a local or remote file system, in a database, or in a <code>.war</code> file.  <p>The servlet container must implement the URL handlers and <code>URLConnection</code> objects that are necessary to access the resource. <p>This method returns <code>null</code> if no resource is mapped to the pathname. <p>Some containers may allow writing to the URL returned by this method using the methods of the URL class. <p>The resource content is returned directly, so be aware that  requesting a <code>.jsp</code> page returns the JSP source code. Use a <code>RequestDispatcher</code> instead to include results of  an execution. <p>This method has a different purpose than <code>java.lang.Class.getResource</code>, which looks up resources based on a class loader. This method does not use class loaders.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>path</CODE> - a <code>String</code> specifying                                                the path to the resource<DT><B>Returns:</B><DD>the resource located at the named path,                                                or <code>null</code> if there is no resource                                                at that path<DT><B>Throws:</B><DD><CODE><A HREF="http://java.sun.com/j2se/1.5/docs/api/java/net/MalformedURLException.html" title="class or interface in java.net">MalformedURLException</A></CODE> - if the pathname is not given in                                                 the correct form</DL></DD></DL><HR><A NAME="getResourceAsStream(java.lang.String)"><!-- --></A><H3>getResourceAsStream</H3><PRE><A HREF="http://java.sun.com/j2se/1.5/docs/api/java/io/InputStream.html" title="class or interface in java.io">InputStream</A> <B>getResourceAsStream</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 the resource located at the named path as an <code>InputStream</code> object. <p>The data in the <code>InputStream</code> can be  of any type or length. The path must be specified according to the rules given in <code>getResource</code>. This method returns <code>null</code> if no resource exists at the specified path.   <p>Meta-information such as content length and content type that is available via <code>getResource</code> method is lost when using this method. <p>The servlet container must implement the URL handlers and <code>URLConnection</code> objects necessary to access the resource. <p>This method is different from  <code>java.lang.Class.getResourceAsStream</code>, which uses a class loader. This method allows servlet containers  to make a resource available to a servlet from any location, without using a class loader.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>path</CODE> - a <code>String</code> specifying the path                        to the resource<DT><B>Returns:</B><DD>the <code>InputStream</code> returned to the                         servlet, or <code>null</code> if no resource                        exists at the specified path</DL></DD></DL><HR><A NAME="getRequestDispatcher(java.lang.String)"><!-- --></A><H3>getRequestDispatcher</H3><PRE><A HREF="../../javax/servlet/RequestDispatcher.html" title="interface in javax.servlet">RequestDispatcher</A> <B>getRequestDispatcher</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 <A HREF="../../javax/servlet/RequestDispatcher.html" title="interface in javax.servlet"><CODE>RequestDispatcher</CODE></A> object that acts as a wrapper for the resource located at the given path. A <code>RequestDispatcher</code> object can be used to forward  a request to the resource or to include the resource in a response. The resource can be dynamic or static. <p>The pathname must begin with a "/" and is interpreted as relative to the current context root.  Use <code>getContext</code> to obtain a <code>RequestDispatcher</code> for resources in foreign contexts. This method returns <code>null</code> if the <code>ServletContext</code> cannot return a <code>RequestDispatcher</code>.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>path</CODE> - a <code>String</code> specifying the pathname                        to the resource<DT><B>Returns:</B><DD>a <code>RequestDispatcher</code> object                        that acts as a wrapper for the resource                        at the specified path, or <code>null</code> if                         the <code>ServletContext</code> cannot return                        a <code>RequestDispatcher</code><DT><B>See Also:</B><DD><A HREF="../../javax/servlet/RequestDispatcher.html" title="interface in javax.servlet"><CODE>RequestDispatcher</CODE></A>, <A HREF="../../javax/servlet/ServletContext.html#getContext(java.lang.String)"><CODE>getContext(java.lang.String)</CODE></A></DL></DD></DL><HR><A NAME="getNamedDispatcher(java.lang.String)"><!-- --></A><H3>getNamedDispatcher</H3><PRE><A HREF="../../javax/servlet/RequestDispatcher.html" title="interface in javax.servlet">RequestDispatcher</A> <B>getNamedDispatcher</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)</PRE><DL><DD>Returns a <A HREF="../../javax/servlet/RequestDispatcher.html" title="interface in javax.servlet"><CODE>RequestDispatcher</CODE></A> object that acts as a wrapper for the named servlet. <p>Servlets (and JSP pages also) may be given names via server  administration or via a web application deployment descriptor. A servlet instance can determine its name using  <A HREF="../../javax/servlet/ServletConfig.html#getServletName()"><CODE>ServletConfig.getServletName()</CODE></A>. <p>This method returns <code>null</code> if the  <code>ServletContext</code> cannot return a <code>RequestDispatcher</code> for any reason.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>name</CODE> - a <code>String</code> specifying the name                        of a servlet to wrap<DT><B>Returns:</B><DD>a <code>RequestDispatcher</code> object                        that acts as a wrapper for the named servlet,                        or <code>null</code> if the <code>ServletContext</code>                        cannot return a <code>RequestDispatcher</code><DT><B>See Also:</B><DD><A HREF="../../javax/servlet/RequestDispatcher.html" title="interface in javax.servlet"><CODE>RequestDispatcher</CODE></A>, <A HREF="../../javax/servlet/ServletContext.html#getContext(java.lang.String)"><CODE>getContext(java.lang.String)</CODE></A>, <A HREF="../../javax/servlet/ServletConfig.html#getServletName()"><CODE>ServletConfig.getServletName()</CODE></A></DL></DD></DL><HR><A NAME="getServlet(java.lang.String)"><!-- --></A><H3>getServlet</H3><PRE><A HREF="../../javax/servlet/Servlet.html" title="interface in javax.servlet">Servlet</A> <B>getServlet</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)                   throws <A HREF="../../javax/servlet/ServletException.html" title="class in javax.servlet">ServletException</A></PRE><DL><DD><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><P><DD><DL><DT><B>Throws:</B><DD><CODE><A HREF="../../javax/servlet/ServletException.html" title="class in javax.servlet">ServletException</A></CODE></DL></DD></DL><HR><A NAME="getServlets()"><!-- --></A><H3>getServlets</H3><PRE><A HREF="http://java.sun.com/j2se/1.5/docs/api/java/util/Enumeration.html" title="class or interface in java.util">Enumeration</A> <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><DD><DL></DL></DD></DL><HR><A NAME="getServletNames()"><!-- --></A><H3>getServletNames</H3><PRE><A HREF="http://java.sun.com/j2se/1.5/docs/api/java/util/Enumeration.html" title="class or interface in java.util">Enumeration</A> <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><DD><DL></DL></DD></DL><HR><A NAME="log(java.lang.String)"><!-- --></A><H3>log</H3><PRE>void <B>log</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)</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.<P><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>void <B>log</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)</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><DD><DL></DL></DD></DL><HR><A NAME="log(java.lang.String, java.lang.Throwable)"><!-- --></A><H3>log</H3><PRE>void <B>log</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)</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.<P><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>

⌨️ 快捷键说明

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