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

📄 javax.servlet.servletcontext.html

📁 servlet-2_4-pfd3-doc.zip 您上载的源码为何会被站长不采用或帐号被删除?
💻 HTML
📖 第 1 页 / 共 2 页
字号:
 <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> path - 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> MalformedURLException    <dd> if the pathname is not given in 						the correct form  </dl></dd></dl><a name="getResourceAsStream(javax.servlet.String)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a><a name="getResourceAsStream"><b>getResourceAsStream</b></a><pre> public abstract InputStream getResourceAsStream(String 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> name - 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><a name="getRequestDispatcher(javax.servlet.String)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a><a name="getRequestDispatcher"><b>getRequestDispatcher</b></a><pre> public abstract <a href="javax.servlet.RequestDispatcher.html#_top_">RequestDispatcher</a> getRequestDispatcher(String path)</pre><dl>  <dd> Returns a {@link RequestDispatcher} 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> path - 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    <dt> <b>See Also:</b>    <dd> <a href="javax.servlet.RequestDispatcher.html#_top_">RequestDispatcher</a>, <a href="#getContext">getContext</a>  </dl></dd></dl><a name="getNamedDispatcher(javax.servlet.String)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a><a name="getNamedDispatcher"><b>getNamedDispatcher</b></a><pre> public abstract <a href="javax.servlet.RequestDispatcher.html#_top_">RequestDispatcher</a> getNamedDispatcher(String name)</pre><dl>  <dd> Returns a {@link RequestDispatcher} 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  {@link ServletConfig#getServletName}. <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> name - 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    <dt> <b>See Also:</b>    <dd> <a href="javax.servlet.RequestDispatcher.html#_top_">RequestDispatcher</a>, <a href="#getContext">getContext</a>, <a href="javax.servlet.ServletConfig.html#getServletName">getServletName</a>  </dl></dd></dl><a name="getServlet(javax.servlet.String)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a><a name="getServlet"><b>getServlet</b></a><pre> public abstract <a href="javax.servlet.Servlet.html#_top_">Servlet</a> getServlet(String name) throws <a href="javax.servlet.ServletException.html#_top_">ServletException</a></pre><dl><dd><b> Note: getServlet() is 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><p></dl><a name="getServlets()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a><a name="getServlets"><b>getServlets</b></a><pre> public abstract Enumeration getServlets()</pre><dl><dd><b> Note: getServlets() is 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><a name="getServletNames()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a><a name="getServletNames"><b>getServletNames</b></a><pre> public abstract Enumeration getServletNames()</pre><dl><dd><b> Note: getServletNames() is 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><a name="log(javax.servlet.String)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a><a name="log"><b>log</b></a><pre> public abstract void log(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.<p>  <dd><dl>    <dt> <b>Parameters:</b>    <dd> msg - a <code>String</code> specifying the			message to be written to the log file  </dl></dd></dl><a name="log(java.lang.Exception, javax.servlet.String)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a><a name="log"><b>log</b></a><pre> public abstract void log(Exception exception,                          String msg)</pre><dl><dd><b> Note: log() is deprecated.</b><i>As of Java Servlet API 2.1, use 			{@link #log(String message, Throwable throwable)} 			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><a name="log(javax.servlet.String, javax.servlet.Throwable)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a><a name="log"><b>log</b></a><pre> public abstract void log(String message,                          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.<p>  <dd><dl>    <dt> <b>Parameters:</b>    <dd> message - a <code>String</code> that				describes the error or exception    <dd> throwable - the <code>Throwable</code> error				or exception  </dl></dd></dl><a name="getRealPath(javax.servlet.String)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a><a name="getRealPath"><b>getRealPath</b></a><pre> public abstract String getRealPath(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).<p>  <dd><dl>    <dt> <b>Parameters:</b>    <dd> path - 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><a name="getServerInfo()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a><a name="getServerInfo"><b>getServerInfo</b></a><pre> public abstract String getServerInfo()</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><a name="getInitParameter(javax.servlet.String)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a><a name="getInitParameter"><b>getInitParameter</b></a><pre> public abstract String getInitParameter(String name)</pre><dl>  <dd> Returns a <code>String</code> containing the value of the named context-wide initialization parameter, or <code>null</code> 

⌨️ 快捷键说明

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