分享
 
 
 

javax.servlet.ServletContext翻译

王朝java/jsp·作者佚名  2006-04-14
窄屏简体版  字體: |||超大  

[/url]

[url=file:///F:/资料/文字资料/j2ee-1.4_doc/apidocs/overview-summary.html]Overview

Package

Class

Tree

Deprecated

Index

Help

JavaTM 2 Platform

Ent. Ed. v1.4

PREV CLASS NEXT CLASS

FRAMES NO FRAMES

All Classes

SUMMARY: NESTED | FIELD | CONSTR | METHOD

DETAIL: FIELD | CONSTR | METHOD

javax.servlet

Interface ServletContext

public interface ServletContext

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. 定义了一组方法,servlet用来和它的servlet容器通信,比如,获得文件的MIME类型,分配请求,或者输出日志文件。

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 /catalog and possibly installed via a .war file.) 每个Java虚拟机的每个web应用都会有一个context。(一个web应用是指安装在服务器的URL命名空间的子集下(比如/catalog)也有可能通过.war文件安装的一组 servlet和内容的组合)。

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. 如果web应用在它的部署描述符中标记为“distributed”,那么每一个虚拟机将只有一个context实例。在这种情况下,context不会用来作为全球共享信息的地址(因为信息不可能真的全球共享),而是使用外部的资源,比如数据库来替代。

The ServletContext object is contained within the ServletConfig object, which the Web server provides the servlet when the servlet is initialized. ServletContext对象被包含于ServletConfig对象内,该对象由servlet初始化时web服务器提供给servlet。

Version: $Version$ Author: Various See Also: Servlet.getServletConfig(), ServletConfig.getServletContext()

Method Summary

Object

getAttribute(String name)

Returns the servlet container attribute with the given name, or null if there is no attribute by that name. 返回给定名称的的servlet容器属性,如果没有该名称的属性,返回null。

Enumeration

getAttributeNames()

Returns an Enumeration containing the attribute names available within this servlet context. 返回servlet上下文中可用的属性枚举。

ServletContext

getContext(String uripath)

Returns a ServletContext object that corresponds to a specified URL on the server. 根据服务器上的指定URL返回ServletContext对象。

String

getInitParameter(String name)

Returns a String containing the value of the named context-wide initialization parameter, or null if the parameter does not exist. 返回等于指定名称的context初始化参数值的String,如果该参数不存在,返回null。

Enumeration

getInitParameterNames()

Returns the names of the context's initialization parameters as an Enumeration of String objects, or an empty Enumeration if the context has no initialization parameters. 以String对象枚举的形式返回context初始化参数的名称,如果context没有初始化参数,返回一个空枚举。

int

getMajorVersion()

Returns the major version of the Java Servlet API that this servlet container supports. 返回servlet容器支持的Java Servlet API的主版本。

String

getMimeType(String file)

Returns the MIME type of the specified file, or null if the MIME type is not known. 返回指定文件的MIME类型,如果MIME类型未知,返回null。

int

getMinorVersion()

Returns the minor version of the Servlet API that this servlet container supports. 返回servlet容器支持的Java Servlet API的次版本。

RequestDispatcher

getNamedDispatcher(String name)

Returns a RequestDispatcher object that acts as a wrapper for the named servlet. 返回一个RequestDispatcher对象,作为给定名称的servlet的包装器。

String

getRealPath(String path)

Returns a String containing the real path for a given virtual path. 由给出的虚拟路径返回真实路径的String。

RequestDispatcher

getRequestDispatcher(String path)

Returns a RequestDispatcher object that acts as a wrapper for the resource located at the given path. 返回一个RequestDispatcher对象,作为位于给定路径的资源包装器。

URL

getResource(String path)

Returns a URL to the resource that is mapped to a specified path. 返回映射到指定路径的资源URL。

InputStream

getResourceAsStream(String path)

Returns the resource located at the named path as an InputStream object. 以InputStream对象形式返回位于指定路径的资源。

Set

getResourcePaths(String path)

Returns a directory-like listing of all the paths to resources within the web application whose longest sub-path matches the supplied path argument. 返回web应用中所有资源路径的列表(类似于目录),它们的完整子路经应匹配提供的路径参数。

String

getServerInfo()

Returns the name and version of the servlet container on which the servlet is running. 返回正在运行servlet的servlet容器名称和版本。

Servlet

getServlet(String name)

Deprecated. As of Java Servlet API 2.1, with no direct replacement. 从Java Servlet API 2.1以来,不再推荐使用。没有替代方法。

This method was originally defined to retrieve a servlet from a ServletContext. In this version, this method always returns null and remains only to preserve binary compatibility. This method will be permanently removed in a future version of the Java Servlet API. 该方法原本定义为从ServletContext获取servlet。在目前版本中,该方法始终返回null,保留该方法仅出于兼容性考虑。在Java Servlet API的以后版本中将会被永久删除。

In lieu of this method, servlets can share information using the ServletContext class and can perform shared business logic by invoking methods on common non-servlet classes. 为了替换该方法,servlet可以使用ServletContext共享信息,也能够通过调用普通的非servlet类的方法来执行共享的业务逻辑。

String

getServletContextName()

Returns the name of this web application correponding to this ServletContext as specified in the deployment descriptor for this web application by the display-name element. 根据web应用中指定部署描述符中display-name元素的ServletContext,返回web应用的名称。

Enumeration

getServletNames()

Deprecated. As of Java Servlet API 2.1, with no replacement. 从Java Servlet API 2.1以来,不再推荐使用。没有替代方法。

This method was originally defined to return an Enumeration of all the servlet names known to this 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. 该方法原本定义为返回该上下文可知的所有servlet名称的枚举。在目前版本中, 该方法始终返回一个空枚举,保留该方法仅出于兼容性考虑。在Java Servlet API的以后版本中将会被永久删除。

Enumeration

getServlets()

Deprecated. As of Java Servlet API 2.0, with no replacement. 从Java Servlet API 2.0以来,不再推荐使用。没有替代方法。

This method was originally defined to return an Enumeration 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. 该方法原本定义为返回servlet上下文可知的所有servlet的枚举。在目前版本中, 该方法始终返回一个空枚举,保留该方法仅出于兼容性考虑。在Java Servlet API的以后版本中将会被永久删除。在Java Servlet API的以后版本中将会被永久删除。

void

log(Exception exception, String msg)

Deprecated. As of Java Servlet API 2.1, use log(String message, Throwable throwable) instead. 从Java Servlet API 2.1以来,使用log(String message, Throwable throwable)代替。

This method was originally defined to write an exception's stack trace and an explanatory error message to the servlet log file. 该方法原本定义为向servlet日志文件写入异常堆栈跟踪和错误说明信息。

void

log(String msg)

Writes the specified message to a servlet log file, usually an event log. 向servlet日志文件写入指定信息,通常为事件日志。

void

log(String message, Throwable throwable)

Writes an explanatory message and a stack trace for a given Throwable exception to the servlet log file. 向servlet日志文件写入错误说明信息和给定Throwable异常堆栈跟踪。

void

removeAttribute(String name)

Removes the attribute with the given name from the servlet context. 从servlet上下文中删除给定名称的属性。

void

setAttribute(String name, Object object)

Binds an object to a given attribute name in this servlet context. 在servlet上下文中绑定对象到给定的属性名。

Method Detail

getContext

public ServletContext getContext(String uripath)

Returns a ServletContext object that corresponds to a specified URL on the server. 根据服务器上的指定URL返回ServletContext对象。

This method allows servlets to gain access to the context for various parts of the server, and as needed obtain RequestDispatcher 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. 该方法允许servlet访问服务器上各种组成的上下文,也是从上下文中获取RequestDispatcher的需要。 路径必须以“/”开头,解释为相对于server文档根路径,对于驻留在容器的其它web应用从上下文根路径匹配。

In a security conscious environment, the servlet container may return null for a given URL. 在一个有安全意识的环境中,servlet容器对于给出的URL可能返回null。

Parameters: uripath - a String specifying the context path of another web application in the container. String,指定容器中另一个web应用的上下文路径。 Returns: the ServletContext object that corresponds to the named URL, or null if either none exists or the container wishes to restrict this access. 符合指定URL的ServletContext对象,如果一个都不存在或者容器希望限制访问,返回null。 See Also: RequestDispatcher

getMajorVersion

public int getMajorVersion()

Returns the major version of the Java Servlet API that this servlet container supports. All implementations that comply with Version 2.4 must have this method return the integer 2. 返回servlet容器支持的Java Servlet API的主版本。所有符合版本2.4的实现方法返回2。

Returns: 2

getMinorVersion

public int getMinorVersion()

Returns the minor version of the Servlet API that this servlet container supports. All implementations that comply with Version 2.4 must have this method return the integer 4. 返回servlet容器支持的Java Servlet API的次版本。所有符合版本2.4的实现方法返回4。

Returns: 4

getMimeType

public String getMimeType(String file)

Returns the MIME type of the specified file, or null 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 "text/html" and "image/gif". 返回指定文件的MIME类型,如果MIME类型未知,返回null。MIME类型 可以由servlet容器的配置决定,也可以由web应用的部署描述符指定。 通常MIME类型为“text/html”和“image/gif”。

Parameters: file - a String specifying the name of a file String,指定文件名 Returns: a String specifying the file's MIME type String,表示文件的MIME类型

getResourcePaths

public Set getResourcePaths(String path)

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 返回web应用中所有资源路径的列表(类似于目录),它们的完整子路径应匹配提供的路径参数。路径表示以‘/’结尾的子目录路径。 返回的路径都相对于web应用的根路径,以‘/’开头。比如,一个web应用包括

/welcome.html

/catalog/index.html

/catalog/products.html

/catalog/offers/books.html

/catalog/offers/music.html

/customer/login.jsp

/WEB-INF/web.xml

/WEB-INF/classes/com.acme.OrderServlet.class,

getResourcePaths("/") returns {"/welcome.html", "/catalog/", "/customer/", "/WEB-INF/"} getResourcePaths("/")返回{"/welcome.html", "/catalog/", "/customer/", "/WEB-INF/"}

getResourcePaths("/catalog/") returns {"/catalog/index.html", "/catalog/products.html", "/catalog/offers/"}. getResourcePaths("/catalog/")返回{"/catalog/index.html", "/catalog/products.html", "/catalog/offers/"}。

Parameters: path - the partial path used to match the resources, which must start with a / 用来匹配资源的部分路径,必须以/开头 Returns: a Set containing the directory listing, or null if there are no resources in the web application whose path begins with the supplied path. Set,表示目录列表,如果web应用中没有路径以提供的路径开头的资源,返回null。 Since: Servlet 2.3

getResource

public URL getResource(String path)

throws MalformedURLException

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. 返回映射到指定路径的资源URL。路径必须以“/”开头,解释为相对于当前上下文根路径。

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 .war file. 该方法允许servlet容器使得任何来源的资源对servlet可用。资源可以位于本地或远程文件系统,数据库,或者.war文件。

The servlet container must implement the URL handlers and URLConnection objects that are necessary to access the resource. servlet容器必须实现URL处理器和URLConnection对象,这些对于访问资源是必需的。

This method returns null if no resource is mapped to the pathname. 如果没有资源映射该路径名,该方法返回null。

Some containers may allow writing to the URL returned by this method using the methods of the URL class. 某些容器允许使用URL类的方法向该方法返回的URL输出。

The resource content is returned directly, so be aware that requesting a .jsp page returns the JSP source code. Use a RequestDispatcher instead to include results of an execution. 资源内容会直接返回,因此要意识到请求一个.jsp页面会返回JSP源代码。要包含执行的结果时,使用RequestDispatcher代替。

This method has a different purpose than java.lang.Class.getResource, which looks up resources based on a class loader. This method does not use class loaders. 该方法和java.lang.Class.getResource目的有一点不同,它基于类加载器 查找资源。本方法不使用类加载器。

Parameters: path - a String specifying the path to the resource String,指定资源路径 Returns: the resource located at the named path, or null if there is no resource at that path 位于指定路径的资源,如果该路径没有资源,返回null Throws: MalformedURLException - if the pathname is not given in the correct form 如果给出的路径名格式不正确抛出

getResourceAsStream

public InputStream getResourceAsStream(String path)

Returns the resource located at the named path as an InputStream object. 以InputStream对象形式返回位于指定路径的资源。

The data in the InputStream can be of any type or length. The path must be specified according to the rules given in getResource. This method returns null if no resource exists at the specified path. InputStream中的数据类型和长度任意。路径必须根据getResource给定的规则指定。 如果指定路径不存在资源,方法返回null。

Meta-information such as content length and content type that is available via getResource method is lost when using this method. 通过getResource方法获得的元信息,比如内容长度和内容类型,会在使用该方法时丢失。

The servlet container must implement the URL handlers and URLConnection objects necessary to access the resource. servlet容器必须实现URL处理器和URLConnection对象,这些对于访问资源是必需的。

This method is different from java.lang.Class.getResourceAsStream, 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. 该方法和java.lang.Class.getResourceAsStream有一点不同,它使用类加载器。 本方法允许servlet容器使得对于任何位置的servlet资源可用,而不使用类加载器。

Parameters: path - a String specifying the path to the resource String,指定资源路径 Returns: the InputStream returned to the servlet, or null if no resource exists at the specified path 返回给servlet的InputStream,如果指定路径不存在资源,返回null

getRequestDispatcher

public RequestDispatcher getRequestDispatcher(String path)

Returns a RequestDispatcher object that acts as a wrapper for the resource located at the given path. A RequestDispatcher 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. 返回一个RequestDispatcher对象,作为位于给定路径的资源包装器。RequestDispatcher 对象可以用来转发对资源的请求或者包含响应中的资源。资源可以是动态或静态。

The pathname must begin with a "/" and is interpreted as relative to the current context root. Use getContext to obtain a RequestDispatcher for resources in foreign contexts. This method returns null if the ServletContext cannot return a RequestDispatcher. 路径必须以“/”开头,解释为相对于当前上下文根路径。使用getContext来获得外部上下文 资源的RequestDispatcher。如果ServletContext不能返回一个RequestDispatcher,方法返回null。

Parameters: path - a String specifying the pathname to the resource String,指定资源的路径名 Returns: a RequestDispatcher object that acts as a wrapper for the resource at the specified path, or null if the ServletContext cannot return a RequestDispatcher RequestDispatcher对象,作为指定路径资源的包装器,如果ServletContext 不能返回一个RequestDispatcher,返回null See Also: RequestDispatcher, getContext(java.lang.String)

getNamedDispatcher

public RequestDispatcher getNamedDispatcher(String name)

Returns a RequestDispatcher object that acts as a wrapper for the named servlet. 返回一个RequestDispatcher对象,作为给定名称的servlet的包装器。

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 ServletConfig.getServletName(). Servlet或者JSP页面可以通过server管理器或web应用部署描述符指定名称。 servlet实例可以使用ServletConfig.getServletName()来确定它的名称。

This method returns null if the ServletContext cannot return a RequestDispatcher for any reason. 如果ServletContext因为某个原因不能返回一个RequestDispatcher,该方法返回null。

Parameters: name - a String specifying the name of a servlet to wrap String,指定要包装的servlet名称 Returns: a RequestDispatcher object that acts as a wrapper for the named servlet, or null if the ServletContext cannot return a RequestDispatcher RequestDispatcher对象,作为指定servlet的包装器,如果ServletContext 不能返回一个RequestDispatcher,返回null See Also: RequestDispatcher, getContext(java.lang.String), ServletConfig.getServletName()

getServlet

public Servlet getServlet(String name)

throws ServletException

Deprecated. As of Java Servlet API 2.1, with no direct replacement. 从Java Servlet API 2.1以来,不再推荐使用。没有替代方法。

This method was originally defined to retrieve a servlet from a ServletContext. In this version, this method always returns null and remains only to preserve binary compatibility. This method will be permanently removed in a future version of the Java Servlet API. 该方法原本定义为从ServletContext获取servlet。在目前版本中,该方法始终返回null,保留下来仅出于兼容性考虑。在Java Servlet API的以后版本中将会被永久删除。

In lieu of this method, servlets can share information using the ServletContext class and can perform shared business logic by invoking methods on common non-servlet classes. 代之以,servlet使用ServletContext类共享信息,普通的非servlet类可以调用方法执行共享的业务逻辑。

Throws: ServletException

getServlets

public Enumeration getServlets()

Deprecated. As of Java Servlet API 2.0, with no replacement. 从Java Servlet API 2.0以来,不再推荐使用。没有替代方法。

This method was originally defined to return an Enumeration 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. 该方法原本定义为返回servlet上下文可知的所有servlet的枚举。在目前版本中, 该方法始终返回一个空枚举,保留该方法仅出于兼容性考虑。在Java Servlet API的以后版本中将会被永久删除。

getServletNames

public Enumeration getServletNames()

Deprecated. As of Java Servlet API 2.1, with no replacement. 从Java Servlet API 2.1以来,不再推荐使用。没有替代方法。

This method was originally defined to return an Enumeration of all the servlet names known to this 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. 该方法原本定义为返回该上下文可知的所有servlet名称的枚举。在目前版本中, 该方法始终返回一个空枚举,保留该方法仅出于兼容性考虑。在Java Servlet API的以后版本中将会被永久删除。

log

public void log(String msg)

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. 向servlet日志文件写入指定信息,通常为事件日志。servlet日志文件的名称和类型 指定给servlet容器。

Parameters: msg - a String specifying the message to be written to the log file String,指定向日志文件输出的消息

log

public void log(Exception exception,

String msg)

Deprecated. As of Java Servlet API 2.1, use log(String message, Throwable throwable) instead. 从Java Servlet API 2.1以来,使用log(String message, Throwable throwable)代替。

This method was originally defined to write an exception's stack trace and an explanatory error message to the servlet log file. 该方法原本定义为向servlet日志文件写入异常堆栈跟踪和错误说明信息。

log

public void log(String message,

Throwable throwable)

Writes an explanatory message and a stack trace for a given Throwable 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. 向servlet日志文件写入错误说明信息和给定Throwable异常堆栈跟踪。 servlet日志文件的名称和类型向servlet容器指定,通常为事件日志。

Parameters: message - a String that describes the error or exception String,描述错误或异常 throwable - the Throwable error or exception Throwable错误或异常

getRealPath

public String getRealPath(String path)

Returns a String 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. 由给出的虚拟路径返回真实路径的String。比如,路径“/index.html”返回“http://host/contextPath/index.html” 请求服务的server的文件系统的绝对文件路径,这里contextPath是ServletContext的上下文路径。

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 null 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 .war archive). 真实路径将以合适的格式返回给运行servlet容器的计算机和操作系统。 如果servlet容器因为某种原因(比如内容正在被.war文件使用)不能将虚拟路径转换成真实路径,方法返回null。

Parameters: path - a String specifying a virtual path String,指定虚拟路径 Returns: a String specifying the real path, or null if the translation cannot be performed String,表示真实路径,如果转换不能执行,返回null

getServerInfo

public String getServerInfo()

Returns the name and version of the servlet container on which the servlet is running. 返回正在运行servlet的servlet容器名称和版本。

The form of the returned string is servername/versionnumber. For example, the JavaServer Web Development Kit may return the string JavaServer Web Dev Kit/1.0. 返回字符串的格式为“服务器名/版本号”。比如,JavaServer Web开发套件可能返回字符串JavaServer Web Dev Kit/1.0。

The servlet container may return other optional information after the primary string in parentheses, for example, JavaServer Web Dev Kit/1.0 (JDK 1.1.6; Windows NT 4.0 x86). servlet容器可能会在基本的字符串之后以括号形式返回其他的可选信息,比如,JavaServer Web Dev Kit/1.0 (JDK 1.1.6; Windows NT 4.0 x86)。

Returns: a String containing at least the servlet container name and version number String,至少包括servlet容器名和版本号

getInitParameter

public String getInitParameter(String name)

Returns a String containing the value of the named context-wide initialization parameter, or null if the parameter does not exist. 返回等于指定名称的context初始化参数值的String,如果该参数不存在,返回null。

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. 该方法使得配置信息对于整个web应用可用。比如,它可以提供一个web管理员的 email地址或者持有关键数据的系统名称。

Parameters: name - a String containing the name of the parameter whose value is requested String,表示请求值的参数 Returns: a String containing at least the servlet container name and version number String,至少包括servlet容器名和版本号 See Also: ServletConfig.getInitParameter(java.lang.String)

getInitParameterNames

public Enumeration getInitParameterNames()

Returns the names of the context's initialization parameters as an Enumeration of String objects, or an empty Enumeration if the context has no initialization parameters. 以String对象枚举的形式返回context初始化参数的名称,如果context没有初始化参数,返回一个空枚举。

Returns: an Enumeration of String objects containing the names of the context's initialization parameters String对象的枚举,表示上下文初始化参数名 See Also: ServletConfig.getInitParameter(java.lang.String)

getAttribute

public Object getAttribute(String name)

Returns the servlet container attribute with the given name, or null 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 getAttributeNames. 返回给定名称的的servlet容器属性,如果没有该名称的属性,返回null。 属性使得servlet容器可以提供给servlet该接口还没有提供的额外信息。关于属性的信息查看server文档。使用getAttributeNames方法可以获得支持的属性列表。

The attribute is returned as a java.lang.Object or some subclass. Attribute names should follow the same convention as package names. The Java Servlet API specification reserves names matching java.*, javax.*, and sun.*. 属性以java.lang.Object或某些子类形式返回。属性命名应该遵循包命名的相同约定。Java Servlet API规范保留匹配java.*, javax.*和sun.*的名称。

Parameters: name - a String specifying the name of the attribute String,指定属性名 Returns: an Object containing the value of the attribute, or null if no attribute exists matching the given name Object,表示属性值,如果存在的属性不匹配给定的名称,返回null See Also: getAttributeNames()

getAttributeNames

public Enumeration getAttributeNames()

Returns an Enumeration containing the attribute names available within this servlet context. Use the getAttribute(java.lang.String) method with an attribute name to get the value of an attribute. 返回servlet上下文中可用的属性枚举。使用带属性名称的getAttribute(java.lang.String)方法可以获得属性值。

Returns: an Enumeration of attribute names 属性名的枚举 See Also: getAttribute(java.lang.String)

setAttribute

public void setAttribute(String name,

Object object)

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. 在servlet上下文中绑定对象到给定的属性名。如果指定的属性名称已使用,该方法 将该属性替换成新的属性。

If listeners are configured on the ServletContext the container notifies them accordingly. 如果ServletContext配置有监听器,容器将因此对其通知。

If a null value is passed, the effect is the same as calling removeAttribute(). 如果传递的值为null,和调用removeAttribute()效果相同。

Attribute names should follow the same convention as package names. The Java Servlet API specification reserves names matching java.*, javax.*, and sun.*. 属性命名应该遵循包命名的相同约定。Java Servlet API规范保留匹配java.*, javax.*和sun.*的名称。

Parameters: name - a String specifying the name of the attribute String,指定属性名 object - an Object representing the attribute to be bound Object,表示要绑定的属性

removeAttribute

public void removeAttribute(String name)

Removes the attribute with the given name from the servlet context. After removal, subsequent calls to getAttribute(java.lang.String) to retrieve the attribute's value will return null. 从servlet上下文中删除给定名称的属性。在删除之后,调用getAttribute(java.lang.String)来获取属性值将返回null。

If listeners are configured on the ServletContext the container notifies them accordingly. 如果ServletContext配置有监听器,容器将因此对其通知。

Parameters: name - a String specifying the name of the attribute to be removed String,指定要删除的属性名

getServletContextName

public String getServletContextName()

Returns the name of this web application correponding to this ServletContext as specified in the deployment descriptor for this web application by the display-name element. 根据web应用中指定部署描述符中display-name元素的ServletContext,返回web应用的名称。

Returns: The name of the web application or null if no name has been declared in the deployment descriptor. web应用的名称,如果没有在部署描述符中声明名称,返回null。 Since: Servlet 2.3 [/url]

[url=file:///F:/资料/文字资料/j2ee-1.4_doc/apidocs/overview-summary.html]Overview

Package

Class

Tree

Deprecated

Index

Help

JavaTM 2 Platform

Ent. Ed. v1.4

PREV CLASS NEXT CLASS

FRAMES NO FRAMES

All Classes

SUMMARY: NESTED | FIELD | CONSTR | METHOD

DETAIL: FIELD | CONSTR | METHOD

Submit a bug or feature

Copyright 2003 Sun Microsystems, Inc. All rights reserved.

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有