org.apache.catalina.core

Class ApplicationContext

Implemented Interfaces:
ServletContext

public class ApplicationContext
extends java.lang.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: 1.25 $ $Date: 2004/04/01 20:09:21 $

Authors:
Craig R. McClanahan
Remy Maucherat

Constructor Summary

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

Method Summary

Object
getAttribute(String name)
Return the value of the specified context attribute, if any; otherwise return null.
Enumeration
getAttributeNames()
Return an enumeration of the names of the context attributes associated with this context.
ServletContext
getContext(String uri)
Return a ServletContext object that corresponds to a specified URI on the server.
protected ServletContext
getFacade()
Return the facade associated with this ApplicationContext.
String
getInitParameter(String name)
Return the value of the specified initialization parameter, or null if this parameter does not exist.
Enumeration
getInitParameterNames()
Return the names of the context's initialization parameters, or an empty enumeration if the context has no initialization parameters.
int
getMajorVersion()
Return the major version of the Java Servlet API that we implement.
String
getMimeType(String file)
Return the MIME type of the specified file, or null if the MIME type cannot be determined.
int
getMinorVersion()
Return the minor version of the Java Servlet API that we implement.
RequestDispatcher
getNamedDispatcher(String name)
Return a RequestDispatcher object that acts as a wrapper for the named servlet.
String
getRealPath(String path)
Return the real path for a given virtual path, if possible; otherwise return null.
RequestDispatcher
getRequestDispatcher(String path)
Return a RequestDispatcher instance that acts as a wrapper for the resource at the given path.
URL
getResource(String path)
Return the URL to the resource that is mapped to a specified path.
InputStream
getResourceAsStream(String path)
Return the requested resource as an InputStream.
Set
getResourcePaths(String path)
Return a Set containing the resource paths of resources member of the specified collection.
DirContext
getResources()
Return the resources object that is mapped to a specified path.
String
getServerInfo()
Return the name and version of the servlet container.
Servlet
getServlet(String name)
Deprecated. As of Java Servlet API 2.1, with no direct replacement.
String
getServletContextName()
Return the display name of this web application.
Enumeration
getServletNames()
Deprecated. As of Java Servlet API 2.1, with no direct replacement.
Enumeration
getServlets()
Deprecated. As of Java Servlet API 2.1, with no direct replacement.
void
log(Exception exception, String message)
Deprecated. As of Java Servlet API 2.1, use log(String, Throwable) instead
void
log(String message)
Writes the specified message to a servlet log file.
void
log(String message, Throwable throwable)
Writes the specified message and exception to a servlet log file.
void
removeAttribute(String name)
Remove the context attribute with the specified name, if any.
void
setAttribute(String name, Object value)
Bind the specified value with the specified context attribute name, replacing any existing value for that name.

Constructor Details

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 Details

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


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


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)
            throws MalformedURLException
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


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(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)
Writes the specified message to a servlet log file.

Parameters:
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 B) 2000-2003 Apache Software Foundation. All Rights Reserved.