FileDocCategorySizeDatePackage
Context.javaAPI DocGlassfish v2 API37173Fri May 04 22:31:52 BST 2007org.apache.catalina

Context

public interface Context implements Container
A Context is a Container that represents a servlet context, and therefore an individual web application, in the Catalina servlet engine. It is therefore useful in almost every deployment of Catalina (even if a Connector attached to a web server (such as Apache) uses the web server's facilities to identify the appropriate Wrapper to handle this request. It also provides a convenient mechanism to use Interceptors that see every request processed by this particular web application.

The parent Container attached to a Context is generally a Host, but may be some other implementation, or may be omitted if it is not necessary.

The child containers attached to a Context are generally implementations of Wrapper (representing individual servlet definitions).

author
Craig R. McClanahan
version
$Revision: 1.4 $ $Date: 2007/05/05 05:31:51 $

Fields Summary
public static final String
RELOAD_EVENT
The LifecycleEvent type sent when a context is reloaded.
Constructors Summary
Methods Summary
public voidaddApplicationListener(java.lang.String listener)
Add a new Listener class name to the set of Listeners configured for this application.

param
listener Java class name of a listener class

public voidaddApplicationParameter(org.apache.catalina.deploy.ApplicationParameter parameter)
Add a new application parameter for this application.

param
parameter The new application parameter

public voidaddConstraint(org.apache.catalina.deploy.SecurityConstraint constraint)
Add a security constraint to the set for this web application.

public voidaddEjb(org.apache.catalina.deploy.ContextEjb ejb)
Add an EJB resource reference for this web application.

param
ejb New EJB resource reference

public voidaddEnvironment(org.apache.catalina.deploy.ContextEnvironment environment)
Add an environment entry for this web application.

param
environment New environment entry

public voidaddErrorPage(org.apache.catalina.deploy.ErrorPage errorPage)
Add an error page for the specified error or Java exception.

param
errorPage The error page definition to be added

public voidaddFilterDef(org.apache.catalina.deploy.FilterDef filterDef)
Add a filter definition to this Context.

param
filterDef The filter definition to be added

public voidaddFilterMap(org.apache.catalina.deploy.FilterMap filterMap)
Add a filter mapping to this Context.

param
filterMap The filter mapping to be added

public voidaddInstanceListener(java.lang.String listener)
Add the classname of an InstanceListener to be added to each Wrapper appended to this Context.

param
listener Java class name of an InstanceListener class

public voidaddJspMapping(java.lang.String pattern)
Add the given URL pattern as a jsp-property-group. This maps resources that match the given pattern so they will be passed to the JSP container. Though there are other elements in the property group, we only care about the URL pattern here. The JSP container will parse the rest.

param
pattern URL pattern to be mapped

public voidaddLocalEjb(org.apache.catalina.deploy.ContextLocalEjb ejb)
Add a local EJB resource reference for this web application.

param
ejb New local EJB resource reference

public voidaddLocaleEncodingMappingParameter(java.lang.String locale, java.lang.String encoding)
Add a Locale Encoding Mapping (see Sec 5.4 of Servlet spec 2.4)

param
locale locale to map an encoding for
param
encoding encoding to be used for a give locale

public voidaddMimeMapping(java.lang.String extension, java.lang.String mimeType)
Add a new MIME mapping, replacing any existing mapping for the specified extension.

param
extension Filename extension being mapped
param
mimeType Corresponding MIME type

public voidaddParameter(java.lang.String name, java.lang.String value)
Add a new context initialization parameter, replacing any existing value for the specified name.

param
name Name of the new parameter
param
value Value of the new parameter

public voidaddResource(org.apache.catalina.deploy.ContextResource resource)
Add a resource reference for this web application.

param
resource New resource reference

public voidaddResourceEnvRef(java.lang.String name, java.lang.String type)
Add a resource environment reference for this web application.

param
name The resource environment reference name
param
type The resource environment reference type

public voidaddResourceLink(org.apache.catalina.deploy.ContextResourceLink resourceLink)
Add a resource link for this web application.

param
resource New resource link

public voidaddRoleMapping(java.lang.String role, java.lang.String link)
Add a security role reference for this web application.

param
role Security role used in the application
param
link Actual security role to check for

public voidaddSecurityRole(java.lang.String role)
Add a new security role for this web application.

param
role New security role

public voidaddServletMapping(java.lang.String pattern, java.lang.String name)
Add a new servlet mapping, replacing any existing mapping for the specified pattern.

param
pattern URL pattern to be mapped
param
name Name of the corresponding servlet to execute

public voidaddTaglib(java.lang.String uri, java.lang.String location)
Add a JSP tag library for the specified URI.

param
uri URI, relative to the web.xml file, of this tag library
param
location Location of the tag library descriptor

public voidaddWelcomeFile(java.lang.String name)
Add a new welcome file to the set recognized by this Context.

param
name New welcome file name

public voidaddWrapperLifecycle(java.lang.String listener)
Add the classname of a LifecycleListener to be added to each Wrapper appended to this Context.

param
listener Java class name of a LifecycleListener class

public voidaddWrapperListener(java.lang.String listener)
Add the classname of a ContainerListener to be added to each Wrapper appended to this Context.

param
listener Java class name of a ContainerListener class

public WrappercreateWrapper()
Factory method to create and return a new Wrapper instance, of the Java implementation class appropriate for this Context implementation. The constructor of the instantiated Wrapper will have been called, but no properties will have been set.

public java.lang.String[]findApplicationListeners()
Return the set of application listener class names configured for this application.

public org.apache.catalina.deploy.ApplicationParameter[]findApplicationParameters()
Return the set of application parameters for this application.

public org.apache.catalina.deploy.SecurityConstraint[]findConstraints()
Return the set of security constraints for this web application. If there are none, a zero-length array is returned.

public org.apache.catalina.deploy.ContextEjbfindEjb(java.lang.String name)
Return the EJB resource reference with the specified name, if any; otherwise, return null.

param
name Name of the desired EJB resource reference

public org.apache.catalina.deploy.ContextEjb[]findEjbs()
Return the defined EJB resource references for this application. If there are none, a zero-length array is returned.

public org.apache.catalina.deploy.ContextEnvironmentfindEnvironment(java.lang.String name)
Return the environment entry with the specified name, if any; otherwise, return null.

param
name Name of the desired environment entry

public org.apache.catalina.deploy.ContextEnvironment[]findEnvironments()
Return the set of defined environment entries for this web application. If none have been defined, a zero-length array is returned.

public org.apache.catalina.deploy.ErrorPagefindErrorPage(int errorCode)
Return the error page entry for the specified HTTP error code, if any; otherwise return null.

param
errorCode Error code to look up

public org.apache.catalina.deploy.ErrorPagefindErrorPage(java.lang.String exceptionType)
Return the error page entry for the specified Java exception type, if any; otherwise return null.

param
exceptionType Exception type to look up

public org.apache.catalina.deploy.ErrorPage[]findErrorPages()
Return the set of defined error pages for all specified error codes and exception types.

public org.apache.catalina.deploy.FilterDeffindFilterDef(java.lang.String filterName)
Return the filter definition for the specified filter name, if any; otherwise return null.

param
filterName Filter name to look up

public org.apache.catalina.deploy.FilterDef[]findFilterDefs()
Return the set of defined filters for this Context.

public org.apache.catalina.deploy.FilterMap[]findFilterMaps()
Return the set of filter mappings for this Context.

public java.lang.String[]findInstanceListeners()
Return the set of InstanceListener classes that will be added to newly created Wrappers automatically.

public org.apache.catalina.deploy.ContextLocalEjbfindLocalEjb(java.lang.String name)
Return the local EJB resource reference with the specified name, if any; otherwise, return null.

param
name Name of the desired EJB resource reference

public org.apache.catalina.deploy.ContextLocalEjb[]findLocalEjbs()
Return the defined local EJB resource references for this application. If there are none, a zero-length array is returned.

public java.lang.StringfindMimeMapping(java.lang.String extension)
Return the MIME type to which the specified extension is mapped, if any; otherwise return null.

param
extension Extension to map to a MIME type

public java.lang.String[]findMimeMappings()
Return the extensions for which MIME mappings are defined. If there are none, a zero-length array is returned.

public java.lang.StringfindParameter(java.lang.String name)
Return the value for the specified context initialization parameter name, if any; otherwise return null.

param
name Name of the parameter to return

public java.lang.String[]findParameters()
Return the names of all defined context initialization parameters for this Context. If no parameters are defined, a zero-length array is returned.

public org.apache.catalina.deploy.ContextResourcefindResource(java.lang.String name)
Return the resource reference with the specified name, if any; otherwise return null.

param
name Name of the desired resource reference

public java.lang.StringfindResourceEnvRef(java.lang.String name)
Return the resource environment reference type for the specified name, if any; otherwise return null.

param
name Name of the desired resource environment reference

public java.lang.String[]findResourceEnvRefs()
Return the set of resource environment reference names for this web application. If none have been specified, a zero-length array is returned.

public org.apache.catalina.deploy.ContextResourceLinkfindResourceLink(java.lang.String name)
Return the resource link with the specified name, if any; otherwise return null.

param
name Name of the desired resource link

public org.apache.catalina.deploy.ContextResourceLink[]findResourceLinks()
Return the defined resource links for this application. If none have been defined, a zero-length array is returned.

public org.apache.catalina.deploy.ContextResource[]findResources()
Return the defined resource references for this application. If none have been defined, a zero-length array is returned.

public java.lang.StringfindRoleMapping(java.lang.String role)
For the given security role (as used by an application), return the corresponding role name (as defined by the underlying Realm) if there is one. Otherwise, return the specified role unchanged.

param
role Security role to map

public booleanfindSecurityRole(java.lang.String role)
Return true if the specified security role is defined for this application; otherwise return false.

param
role Security role to verify

public java.lang.String[]findSecurityRoles()
Return the security roles defined for this application. If none have been defined, a zero-length array is returned.

public java.lang.StringfindServletMapping(java.lang.String pattern)
Return the servlet name mapped by the specified pattern (if any); otherwise return null.

param
pattern Pattern for which a mapping is requested

public java.lang.String[]findServletMappings()
Return the patterns of all defined servlet mappings for this Context. If no mappings are defined, a zero-length array is returned.

public java.lang.StringfindStatusPage(int status)
Return the context-relative URI of the error page for the specified HTTP status code, if any; otherwise return null.

param
status HTTP status code to look up

public int[]findStatusPages()
Return the set of HTTP status codes for which error pages have been specified. If none are specified, a zero-length array is returned.

public java.lang.StringfindTaglib(java.lang.String uri)
Return the tag library descriptor location for the specified taglib URI, if any; otherwise, return null.

param
uri URI, relative to the web.xml file

public java.lang.String[]findTaglibs()
Return the URIs of all tag libraries for which a tag library descriptor location has been specified. If none are specified, a zero-length array is returned.

public booleanfindWelcomeFile(java.lang.String name)
Return true if the specified welcome file is defined for this Context; otherwise return false.

param
name Welcome file to verify

public java.lang.String[]findWelcomeFiles()
Return the set of welcome files defined for this Context. If none are defined, a zero-length array is returned.

public java.lang.String[]findWrapperLifecycles()
Return the set of LifecycleListener classes that will be added to newly created Wrappers automatically.

public java.lang.String[]findWrapperListeners()
Return the set of ContainerListener classes that will be added to newly created Wrappers automatically.

public java.lang.StringgetAdHocServletName(java.lang.String path)
Returns the name of the ad-hoc servlet responsible for servicing the given path.

param
path The path to service
return
The name of the ad-hoc servlet responsible for servicing the given path, or null if the given path is not an ad-hoc path

public booleangetAllowRelativeRedirect()
Return whether this context allows sendRedirect() to redirect to a relative URL. The default value for this property is 'false'.

public java.lang.StringgetAltDDName()
Return the alternate Deployment Descriptor name.

public java.lang.Object[]getApplicationEventListeners()
Return the set of initialized application event listener objects, in the order they were specified in the web application deployment descriptor, for this application.

exception
IllegalStateException if this method is called before this application has started, or after it has been stopped

public java.lang.Object[]getApplicationLifecycleListeners()
Return the set of initialized application lifecycle listener objects, in the order they were specified in the web application deployment descriptor, for this application.

exception
IllegalStateException if this method is called before this application has started, or after it has been stopped

public Auditor[]getAuditors()
Get Auditors associated with this context, if any.

return
array of Auditor objects, or null

public booleangetAvailable()
Return the application available flag for this Context.

public org.apache.catalina.util.CharsetMappergetCharsetMapper()
Return the Locale to character set mapper for this Context.

public java.lang.StringgetConfigFile()
Return the path to a file to save this Context information.

public booleangetConfigured()
Return the "correctly configured" flag for this Context.

public booleangetCookies()
Return the "use cookies for session ids" flag.

public booleangetCrossContext()
Return the "allow crossing servlet contexts" flag.

public java.lang.StringgetDisplayName()
Return the display name of this web application.

public booleangetDistributable()
Return the distributable flag for this web application.

public java.lang.StringgetDocBase()
Return the document root for this Context. This can be an absolute pathname, a relative pathname, or a URL.

public java.lang.StringgetEncodedPath()
Return the URL encoded context path, using UTF-8.

public org.apache.catalina.deploy.LoginConfiggetLoginConfig()
Return the login configuration descriptor for this web application.

public org.apache.tomcat.util.http.mapper.MappergetMapper()
Get the request dispatcher mapper.

public org.apache.catalina.deploy.NamingResourcesgetNamingResources()
Return the naming resources associated with this web application.

public booleangetOverride()
Return the override flag for this web application.

public java.lang.StringgetPath()
Return the context path for this web application.

public booleangetPrivileged()
Return the privileged flag for this web application.

public java.lang.StringgetPublicId()
Return the public identifier of the deployment descriptor DTD that is currently being parsed.

public booleangetReloadable()
Return the reloadable flag for this web application.

public booleangetReuseSessionID()
Return the "reuse session IDs when creating sessions" flag

public javax.servlet.ServletContextgetServletContext()
Return the servlet context for which this Context is a facade.

public intgetSessionTimeout()
Return the default session timeout (in minutes) for this web application.

public booleangetTldNamespaceAware()
Get the server.xml attribute's xmlNamespaceAware.

return
true if namespace awarenes is enabled.

public booleangetTldValidation()
Get the server.xml attribute's webXmlValidation.

return
true if validation is enabled.

public java.lang.StringgetWrapperClass()
Return the Java class name of the Wrapper implementation used for servlets registered in this Context.

public booleangetXmlNamespaceAware()
Get the server.xml attribute's xmlNamespaceAware.

return
true if namespace awarenes is enabled.

public booleangetXmlValidation()
Get the server.xml attribute's xmlValidation.

return
true if validation is enabled.

public booleanhasAdHocPaths()
Indicates whether this web module contains any ad-hoc paths. An ad-hoc path is a servlet path that is mapped to a servlet not declared in the web module's deployment descriptor. A web module all of whose mappings are for ad-hoc paths is called an ad-hoc web module.

return
true if this web module contains any ad-hoc paths, false otherwise

public booleanisJsfApplication()
Return true if this context contains the JSF servlet.

public booleanisSecurePagesWithPragma()
Indicates whether the Pragma and Cache-Control headers will be set to "No-cache" if proxy caching has been disabled.

return
true if Pragma and Cache-Control headers will be set to "No-cache" if proxy caching has been disabled; false otherwise.

public voidreload()
Reload this web application, if reloading is supported.

exception
IllegalStateException if the reloadable property is set to false.

public voidremoveApplicationListener(java.lang.String listener)
Remove the specified application listener class from the set of listeners for this application.

param
listener Java class name of the listener to be removed

public voidremoveApplicationParameter(java.lang.String name)
Remove the application parameter with the specified name from the set for this application.

param
name Name of the application parameter to remove

public voidremoveConstraint(org.apache.catalina.deploy.SecurityConstraint constraint)
Remove the specified security constraint from this web application.

param
constraint Constraint to be removed

public voidremoveEjb(java.lang.String name)
Remove any EJB resource reference with the specified name.

param
name Name of the EJB resource reference to remove

public voidremoveEnvironment(java.lang.String name)
Remove any environment entry with the specified name.

param
name Name of the environment entry to remove

public voidremoveErrorPage(org.apache.catalina.deploy.ErrorPage errorPage)
Remove the error page for the specified error code or Java language exception, if it exists; otherwise, no action is taken.

param
errorPage The error page definition to be removed

public voidremoveFilterDef(org.apache.catalina.deploy.FilterDef filterDef)
Remove the specified filter definition from this Context, if it exists; otherwise, no action is taken.

param
filterDef Filter definition to be removed

public voidremoveFilterMap(org.apache.catalina.deploy.FilterMap filterMap)
Remove a filter mapping from this Context.

param
filterMap The filter mapping to be removed

public voidremoveInstanceListener(java.lang.String listener)
Remove a class name from the set of InstanceListener classes that will be added to newly created Wrappers.

param
listener Class name of an InstanceListener class to be removed

public voidremoveLocalEjb(java.lang.String name)
Remove any local EJB resource reference with the specified name.

param
name Name of the EJB resource reference to remove

public voidremoveMimeMapping(java.lang.String extension)
Remove the MIME mapping for the specified extension, if it exists; otherwise, no action is taken.

param
extension Extension to remove the mapping for

public voidremoveParameter(java.lang.String name)
Remove the context initialization parameter with the specified name, if it exists; otherwise, no action is taken.

param
name Name of the parameter to remove

public voidremoveResource(java.lang.String name)
Remove any resource reference with the specified name.

param
name Name of the resource reference to remove

public voidremoveResourceEnvRef(java.lang.String name)
Remove any resource environment reference with the specified name.

param
name Name of the resource environment reference to remove

public voidremoveResourceLink(java.lang.String name)
Remove any resource link with the specified name.

param
name Name of the resource link to remove

public voidremoveRoleMapping(java.lang.String role)
Remove any security role reference for the specified name

param
role Security role (as used in the application) to remove

public voidremoveSecurityRole(java.lang.String role)
Remove any security role with the specified name.

param
role Security role to remove

public voidremoveServletMapping(java.lang.String pattern)
Remove any servlet mapping for the specified pattern, if it exists; otherwise, no action is taken.

param
pattern URL pattern of the mapping to remove

public voidremoveTaglib(java.lang.String uri)
Remove the tag library location forthe specified tag library URI.

param
uri URI, relative to the web.xml file

public voidremoveWelcomeFile(java.lang.String name)
Remove the specified welcome file name from the list recognized by this Context.

param
name Name of the welcome file to be removed

public voidremoveWrapperLifecycle(java.lang.String listener)
Remove a class name from the set of LifecycleListener classes that will be added to newly created Wrappers.

param
listener Class name of a LifecycleListener class to be removed

public voidremoveWrapperListener(java.lang.String listener)
Remove a class name from the set of ContainerListener classes that will be added to newly created Wrappers.

param
listener Class name of a ContainerListener class to be removed

public voidsetAllowRelativeRedirect(boolean allowRelativeURLs)
Set whether this context allows sendRedirect() to redirect to a relative URL.

param
allowRelativeURLs The new value for this property. The default value for this flag is 'false'.

public voidsetAltDDName(java.lang.String altDDName)
Set an alternate Deployment Descriptor name.

public voidsetApplicationEventListeners(java.lang.Object[] listeners)
Store the set of initialized application event listener objects, in the order they were specified in the web application deployment descriptor, for this application.

param
listeners The set of instantiated listener objects.

public voidsetApplicationLifecycleListeners(java.lang.Object[] listeners)
Store the set of initialized application lifecycle listener objects, in the order they were specified in the web application deployment descriptor, for this application.

param
listeners The set of instantiated listener objects.

public voidsetAuditors(Auditor[] auditor)
Set the Auditors associated with this context.

param
auditor array of Auditor objects

public voidsetAvailable(boolean available)
Set the application available flag for this Context.

param
available The new application available flag

public voidsetCharsetMapper(org.apache.catalina.util.CharsetMapper mapper)
Set the Locale to character set mapper for this Context.

param
mapper The new mapper

public voidsetConfigFile(java.lang.String configFile)
Set the path to a file to save this Context information.

param
configFile The path to a file to save this Context information.

public voidsetConfigured(boolean configured)
Set the "correctly configured" flag for this Context. This can be set to false by startup listeners that detect a fatal configuration error to avoid the application from being made available.

param
configured The new correctly configured flag

public voidsetCookies(boolean cookies)
Set the "use cookies for session ids" flag.

param
cookies The new flag

public voidsetCrossContext(boolean crossContext)
Set the "allow crossing servlet contexts" flag.

param
crossContext The new cross contexts flag

public voidsetDisplayName(java.lang.String displayName)
Set the display name of this web application.

param
displayName The new display name

public voidsetDistributable(boolean distributable)
Set the distributable flag for this web application.

param
distributable The new distributable flag

public voidsetDocBase(java.lang.String docBase)
Set the document root for this Context. This can be an absolute pathname, a relative pathname, or a URL.

param
docBase The new document root

public voidsetLoginConfig(org.apache.catalina.deploy.LoginConfig config)
Set the login configuration descriptor for this web application.

param
config The new login configuration

public voidsetNamingResources(org.apache.catalina.deploy.NamingResources namingResources)
Set the naming resources for this web application.

param
namingResources The new naming resources

public voidsetOverride(boolean override)
Set the override flag for this web application.

param
override The new override flag

public voidsetPath(java.lang.String path)
Set the context path for this web application.

param
path The new context path

public voidsetPrivileged(boolean privileged)
Set the privileged flag for this web application.

param
privileged The new privileged flag

public voidsetPublicId(java.lang.String publicId)
Set the public identifier of the deployment descriptor DTD that is currently being parsed.

param
publicId The public identifier

public voidsetReloadable(boolean reloadable)
Set the reloadable flag for this web application.

param
reloadable The new reloadable flag

public voidsetReuseSessionID(boolean reuse)
Set the "reuse session IDs when creating sessions" flag

param
reuse The new value for the flag

public voidsetSecurePagesWithPragma(boolean securePagesWithPragma)
Sets the securePagesWithPragma property of this Context. Setting this property to true will result in Pragma and Cache-Control headers with a value of "No-cache" if proxy caching has been disabled. Setting this property to false will not add any Pragma header, but will set the Cache-Control header to "private".

param
securePagesWithPragma true if Pragma and Cache-Control headers are to be set to "No-cache" if proxy caching has been disabled, false otherwise

public voidsetSessionTimeout(int timeout)
Set the default session timeout (in minutes) for this web application.

param
timeout The new default session timeout

public voidsetTldNamespaceAware(boolean tldNamespaceAware)
Set the namespace aware feature of the XML parser used when parsing xml instances.

param
xmlNamespaceAware true to enable namespace awareness

public voidsetTldValidation(boolean tldValidation)
Set the validation feature of the XML parser used when parsing tlds files.

param
tldXmlValidation true to enable xml instance validation

public voidsetWrapperClass(java.lang.String wrapperClass)
Set the Java class name of the Wrapper implementation used for servlets registered in this Context.

param
wrapperClass The new wrapper class

public voidsetXmlNamespaceAware(boolean xmlNamespaceAware)
Set the namespace aware feature of the XML parser used when parsing xml instances.

param
xmlNamespaceAware true to enable namespace awareness

public voidsetXmlValidation(boolean xmlValidation)
Set the validation feature of the XML parser used when parsing xml instances.

param
xmlValidation true to enable xml instance validation