org.apache.catalina.core

Class ApplicationContext

public class ApplicationContext extends Object implements ServletContext

Standard implementation of ServletContext that represents a web application's execution environment. An instance of this class is associated with each instance of StandardContext.

Version: $Revision: 739532 $ $Date: 2009-01-31 10:52:13 +0100 (Sat, 31 Jan 2009) $

Author: Craig R. McClanahan Remy Maucherat

Field Summary
protected Mapattributes
The context attributes for this context.
Constructor Summary
ApplicationContext(String basePath, StandardContext context)
Construct a new instance of this class, associated with the specified Context instance.
Method Summary
protected voidclearAttributes()
Clear all application-created attributes.
ObjectgetAttribute(String name)
Return the value of the specified context attribute, if any; otherwise return null.
EnumerationgetAttributeNames()
Return an enumeration of the names of the context attributes associated with this context.
ServletContextgetContext(String uri)
Return a ServletContext object that corresponds to a specified URI on the server.
protected StandardContextgetContext()
StringgetContextPath()
Return the main path associated with this context.
protected ServletContextgetFacade()
Return the facade associated with this ApplicationContext.
StringgetInitParameter(String name)
Return the value of the specified initialization parameter, or null if this parameter does not exist.
EnumerationgetInitParameterNames()
Return the names of the context's initialization parameters, or an empty enumeration if the context has no initialization parameters.
intgetMajorVersion()
Return the major version of the Java Servlet API that we implement.
StringgetMimeType(String file)
Return the MIME type of the specified file, or null if the MIME type cannot be determined.
intgetMinorVersion()
Return the minor version of the Java Servlet API that we implement.
RequestDispatchergetNamedDispatcher(String name)
Return a RequestDispatcher object that acts as a wrapper for the named servlet.
protected MapgetReadonlyAttributes()
StringgetRealPath(String path)
Return the real path for a given virtual path, if possible; otherwise return null.
RequestDispatchergetRequestDispatcher(String path)
Return a RequestDispatcher instance that acts as a wrapper for the resource at the given path.
URLgetResource(String path)
Return the URL to the resource that is mapped to a specified path.
InputStreamgetResourceAsStream(String path)
Return the requested resource as an InputStream.
SetgetResourcePaths(String path)
Return a Set containing the resource paths of resources member of the specified collection.
DirContextgetResources()
Return the resources object that is mapped to a specified path.
StringgetServerInfo()
Return the name and version of the servlet container.
ServletgetServlet(String name)
StringgetServletContextName()
Return the display name of this web application.
EnumerationgetServletNames()
EnumerationgetServlets()
voidlog(String message)
Writes the specified message to a servlet log file.
voidlog(Exception exception, String message)
Writes the specified exception and message to a servlet log file.
voidlog(String message, Throwable throwable)
Writes the specified message and exception to a servlet log file.
voidremoveAttribute(String name)
Remove the context attribute with the specified name, if any.
voidsetAttribute(String name, Object value)
Bind the specified value with the specified context attribute name, replacing any existing value for that name.

Field Detail

attributes

protected Map attributes
The context attributes for this context.

Constructor Detail

ApplicationContext

public ApplicationContext(String basePath, StandardContext context)
Construct a new instance of this class, associated with the specified Context instance.

Parameters: context The associated Context instance

Method Detail

clearAttributes

protected void clearAttributes()
Clear all application-created attributes.

getAttribute

public Object getAttribute(String name)
Return the value of the specified context attribute, if any; otherwise return null.

Parameters: name Name of the context attribute to return

getAttributeNames

public Enumeration getAttributeNames()
Return an enumeration of the names of the context attributes associated with this context.

getContext

public ServletContext getContext(String uri)
Return a ServletContext object that corresponds to a specified URI on the server. This method allows servlets to gain access to the context for various parts of the server, and as needed obtain RequestDispatcher objects or resources from the context. The given path must be absolute (beginning with a "/"), and is interpreted based on our virtual host's document root.

Parameters: uri Absolute URI of a resource on the server

getContext

protected StandardContext getContext()

getContextPath

public String getContextPath()
Return the main path associated with this context.

getFacade

protected ServletContext getFacade()
Return the facade associated with this ApplicationContext.

getInitParameter

public String getInitParameter(String name)
Return the value of the specified initialization parameter, or null if this parameter does not exist.

Parameters: name Name of the initialization parameter to retrieve

getInitParameterNames

public Enumeration getInitParameterNames()
Return the names of the context's initialization parameters, or an empty enumeration if the context has no initialization parameters.

getMajorVersion

public int getMajorVersion()
Return the major version of the Java Servlet API that we implement.

getMimeType

public String getMimeType(String file)
Return the MIME type of the specified file, or null if the MIME type cannot be determined.

Parameters: file Filename for which to identify a MIME type

getMinorVersion

public int getMinorVersion()
Return the minor version of the Java Servlet API that we implement.

getNamedDispatcher

public RequestDispatcher getNamedDispatcher(String name)
Return a RequestDispatcher object that acts as a wrapper for the named servlet.

Parameters: name Name of the servlet for which a dispatcher is requested

getReadonlyAttributes

protected Map getReadonlyAttributes()

getRealPath

public String getRealPath(String path)
Return the real path for a given virtual path, if possible; otherwise return null.

Parameters: path The path to the desired resource

getRequestDispatcher

public RequestDispatcher getRequestDispatcher(String path)
Return a RequestDispatcher instance that acts as a wrapper for the resource at the given path. The path must begin with a "/" and is interpreted as relative to the current context root.

Parameters: path The path to the desired resource.

getResource

public URL getResource(String path)
Return the 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.

Parameters: path The path to the desired resource

Throws: MalformedURLException if the path is not given in the correct form

getResourceAsStream

public InputStream getResourceAsStream(String path)
Return the requested resource as an InputStream. The path must be specified according to the rules described under getResource. If no such resource can be identified, return null.

Parameters: path The path to the desired resource.

getResourcePaths

public Set getResourcePaths(String path)
Return a Set containing the resource paths of resources member of the specified collection. Each path will be a String starting with a "/" character. The returned set is immutable.

Parameters: path Collection path

getResources

public DirContext getResources()
Return the resources object that is mapped to a specified path. The path must begin with a "/" and is interpreted as relative to the current context root.

getServerInfo

public String getServerInfo()
Return the name and version of the servlet container.

getServlet

public Servlet getServlet(String name)

Deprecated: As of Java Servlet API 2.1, with no direct replacement.

getServletContextName

public String getServletContextName()
Return the display name of this web application.

getServletNames

public Enumeration getServletNames()

Deprecated: As of Java Servlet API 2.1, with no direct replacement.

getServlets

public Enumeration getServlets()

Deprecated: As of Java Servlet API 2.1, with no direct replacement.

log

public void log(String message)
Writes the specified message to a servlet log file.

Parameters: message Message to be written

log

public void log(Exception exception, String message)

Deprecated: As of Java Servlet API 2.1, use log(String, Throwable) instead

Writes the specified exception and message to a servlet log file.

Parameters: exception Exception to be reported message Message to be written

log

public void log(String message, Throwable throwable)
Writes the specified message and exception to a servlet log file.

Parameters: message Message to be written throwable Exception to be reported

removeAttribute

public void removeAttribute(String name)
Remove the context attribute with the specified name, if any.

Parameters: name Name of the context attribute to be removed

setAttribute

public void setAttribute(String name, Object value)
Bind the specified value with the specified context attribute name, replacing any existing value for that name.

Parameters: name Attribute name to be bound value New attribute value to be bound

Copyright © 2000-2011 Apache Software Foundation. All Rights Reserved.