Apache Tomcat 7.0.28

org.apache.catalina
Interface Context

All Superinterfaces:
Container, Lifecycle
All Known Implementing Classes:
FailedContext, ReplicatedContext, StandardContext

public interface Context
extends 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).

Version:
$Id: Context.java 1350247 2012-06-14 14:04:20Z markt $
Author:
Craig R. McClanahan

Field Summary
static String ADD_WELCOME_FILE_EVENT
          Container event for adding a welcome file.
static String CHANGE_SESSION_ID_EVENT
          Container event for changing the ID of a session.
static String CLEAR_WELCOME_FILES_EVENT
          Container event for clearing welcome files.
static String RELOAD_EVENT
          Deprecated. Will be removed in Tomcat 8.0.x onwards.
static String REMOVE_WELCOME_FILE_EVENT
          Container event for removing a wrapper.
 
Fields inherited from interface org.apache.catalina.Container
ADD_CHILD_EVENT, ADD_MAPPER_EVENT, ADD_VALVE_EVENT, REMOVE_CHILD_EVENT, REMOVE_MAPPER_EVENT, REMOVE_VALVE_EVENT
 
Fields inherited from interface org.apache.catalina.Lifecycle
AFTER_DESTROY_EVENT, AFTER_INIT_EVENT, AFTER_START_EVENT, AFTER_STOP_EVENT, BEFORE_DESTROY_EVENT, BEFORE_INIT_EVENT, BEFORE_START_EVENT, BEFORE_STOP_EVENT, CONFIGURE_START_EVENT, CONFIGURE_STOP_EVENT, PERIODIC_EVENT, START_EVENT, STOP_EVENT
 
Method Summary
 void addApplicationListener(String listener)
          Add a new Listener class name to the set of Listeners configured for this application.
 void addApplicationParameter(ApplicationParameter parameter)
          Add a new application parameter for this application.
 void addConstraint(SecurityConstraint constraint)
          Add a security constraint to the set for this web application.
 void addErrorPage(ErrorPage errorPage)
          Add an error page for the specified error or Java exception.
 void addFilterDef(FilterDef filterDef)
          Add a filter definition to this Context.
 void addFilterMap(FilterMap filterMap)
          Add a filter mapping to this Context.
 void addFilterMapBefore(FilterMap filterMap)
          Add a filter mapping to this Context before the mappings defined in the deployment descriptor but after any other mappings added via this method.
 void addInstanceListener(String listener)
          Add the classname of an InstanceListener to be added to each Wrapper appended to this Context.
 void addLocaleEncodingMappingParameter(String locale, String encoding)
          Add a Locale Encoding Mapping (see Sec 5.4 of Servlet spec 2.4)
 void addMimeMapping(String extension, String mimeType)
          Add a new MIME mapping, replacing any existing mapping for the specified extension.
 void addParameter(String name, String value)
          Add a new context initialization parameter, replacing any existing value for the specified name.
 void addResourceJarUrl(URL url)
          Add a URL for a JAR that contains static resources in a META-INF/resources directory that should be included in the static resources for this context.
 void addRoleMapping(String role, String link)
          Add a security role reference for this web application.
 void addSecurityRole(String role)
          Add a new security role for this web application.
 void addServletContainerInitializer(ServletContainerInitializer sci, Set<Class<?>> classes)
          Add a ServletContainerInitializer instance to this web application.
 void addServletMapping(String pattern, String name)
          Add a new servlet mapping, replacing any existing mapping for the specified pattern.
 void addServletMapping(String pattern, String name, boolean jspWildcard)
          Add a new servlet mapping, replacing any existing mapping for the specified pattern.
 Set<String> addServletSecurity(ApplicationServletRegistration registration, ServletSecurityElement servletSecurityElement)
          Notification that servlet security has been dynamically set in a ServletRegistration.Dynamic
 void addWatchedResource(String name)
          Add a resource which will be watched for reloading by the host auto deployer.
 void addWelcomeFile(String name)
          Add a new welcome file to the set recognized by this Context.
 void addWrapperLifecycle(String listener)
          Add the classname of a LifecycleListener to be added to each Wrapper appended to this Context.
 void addWrapperListener(String listener)
          Add the classname of a ContainerListener to be added to each Wrapper appended to this Context.
 Wrapper createWrapper()
          Factory method to create and return a new Wrapper instance, of the Java implementation class appropriate for this Context implementation.
 String[] findApplicationListeners()
          Return the set of application listener class names configured for this application.
 ApplicationParameter[] findApplicationParameters()
          Return the set of application parameters for this application.
 SecurityConstraint[] findConstraints()
          Return the set of security constraints for this web application.
 ErrorPage findErrorPage(int errorCode)
          Return the error page entry for the specified HTTP error code, if any; otherwise return null.
 ErrorPage findErrorPage(String exceptionType)
          Return the error page entry for the specified Java exception type, if any; otherwise return null.
 ErrorPage[] findErrorPages()
          Return the set of defined error pages for all specified error codes and exception types.
 FilterDef findFilterDef(String filterName)
          Return the filter definition for the specified filter name, if any; otherwise return null.
 FilterDef[] findFilterDefs()
          Return the set of defined filters for this Context.
 FilterMap[] findFilterMaps()
          Return the set of filter mappings for this Context.
 String[] findInstanceListeners()
          Return the set of InstanceListener classes that will be added to newly created Wrappers automatically.
 String findMimeMapping(String extension)
          Return the MIME type to which the specified extension is mapped, if any; otherwise return null.
 String[] findMimeMappings()
          Return the extensions for which MIME mappings are defined.
 String findParameter(String name)
          Return the value for the specified context initialization parameter name, if any; otherwise return null.
 String[] findParameters()
          Return the names of all defined context initialization parameters for this Context.
 String findRoleMapping(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.
 boolean findSecurityRole(String role)
          Return true if the specified security role is defined for this application; otherwise return false.
 String[] findSecurityRoles()
          Return the security roles defined for this application.
 String findServletMapping(String pattern)
          Return the servlet name mapped by the specified pattern (if any); otherwise return null.
 String[] findServletMappings()
          Return the patterns of all defined servlet mappings for this Context.
 String findStatusPage(int status)
          Return the context-relative URI of the error page for the specified HTTP status code, if any; otherwise return null.
 int[] findStatusPages()
          Return the set of HTTP status codes for which error pages have been specified.
 String[] findWatchedResources()
          Return the set of watched resources for this Context.
 boolean findWelcomeFile(String name)
          Return true if the specified welcome file is defined for this Context; otherwise return false.
 String[] findWelcomeFiles()
          Return the set of welcome files defined for this Context.
 String[] findWrapperLifecycles()
          Return the set of LifecycleListener classes that will be added to newly created Wrappers automatically.
 String[] findWrapperListeners()
          Return the set of ContainerListener classes that will be added to newly created Wrappers automatically.
 boolean fireRequestDestroyEvent(ServletRequest request)
          Notify all ServletRequestListeners that a request has ended.
 boolean fireRequestInitEvent(ServletRequest request)
          Notify all ServletRequestListeners that a request has started.
 boolean getAllowCasualMultipartParsing()
          Returns true if requests mapped to servlets without "multipart config" to parse multipart/form-data requests anyway.
 String getAltDDName()
          Return the alternate Deployment Descriptor name.
 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.
 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.
 Authenticator getAuthenticator()
          Obtain the Authenticator that is used by this context or null if none is used.
 boolean getAvailable()
          Return the application available flag for this Context.
 String getBaseName()
          Return the base name to use for WARs, directories or context.xml files for this context.
 String getCharset(Locale locale)
          Obtain the character set name to use with the given Locale.
 CharsetMapper getCharsetMapper()
          Deprecated. Use getCharset(Locale)
 URL getConfigFile()
          Return the URL of the XML descriptor for this context.
 boolean getConfigured()
          Return the "correctly configured" flag for this Context.
 boolean getCookies()
          Return the "use cookies for session ids" flag.
 boolean getCrossContext()
          Return the "allow crossing servlet contexts" flag.
 String getDisplayName()
          Return the display name of this web application.
 boolean getDistributable()
          Return the distributable flag for this web application.
 String getDocBase()
          Return the document root for this Context.
 int getEffectiveMajorVersion()
          Return the effective major version of the Servlet spec used by this context.
 int getEffectiveMinorVersion()
          Return the effective minor version of the Servlet spec used by this context.
 String getEncodedPath()
          Return the URL encoded context path, using UTF-8.
 boolean getFireRequestListenersOnForwards()
          Determine whether or not requests listeners will be fired on forwards for this Context.
 boolean getIgnoreAnnotations()
          Return the boolean on the annotations parsing.
 JarScanner getJarScanner()
          Get the Jar Scanner to be used to scan for JAR resources for this context.
 JspConfigDescriptor getJspConfigDescriptor()
          Obtain the JSP configuration for this context.
 boolean getLogEffectiveWebXml()
          Should the effective web.xml for this context be logged on context start?
 LoginConfig getLoginConfig()
          Return the login configuration descriptor for this web application.
 Mapper getMapper()
          Get the request dispatcher mapper.
 NamingResources getNamingResources()
          Return the naming resources associated with this web application.
 boolean getOverride()
          Return the override flag for this web application.
 String getPath()
          Return the context path for this web application.
 boolean getPaused()
          Is this Context paused whilst it is reloaded?
 boolean getPreemptiveAuthentication()
          Determines if a user presents authentication credentials, will the context will process them when the request is for a non-protected resource.
 boolean getPrivileged()
          Return the privileged flag for this web application.
 String getPublicId()
          Return the public identifier of the deployment descriptor DTD that is currently being parsed.
 String getRealPath(String path)
          Return the real path for a given virtual path, if possible; otherwise return null.
 boolean getReloadable()
          Return the reloadable flag for this web application.
 String getResourceOnlyServlets()
          Obtains the list of Servlets that expect a resource to be present.
 boolean getSendRedirectBody()
          Determines if the context is configured to include a response body as part of a redirect response.
 ServletContext getServletContext()
          Return the servlet context for which this Context is a facade.
 String getSessionCookieDomain()
          Gets the domain to use for session cookies.
 String getSessionCookieName()
          Gets the name to use for session cookies.
 String getSessionCookiePath()
          Gets the path to use for session cookies.
 boolean getSessionCookiePathUsesTrailingSlash()
          Is a / added to the end of the session cookie path to ensure browsers, particularly IE, don't send a session cookie for context /foo with requests intended for context /foobar.
 int getSessionTimeout()
          Return the default session timeout (in minutes) for this web application.
 boolean getSwallowAbortedUploads()
          Returns true if remaining request data will be read (swallowed) even the request violates a data size constraint.
 boolean getSwallowOutput()
          Return the value of the swallowOutput flag.
 boolean getTldNamespaceAware()
          Get the server.xml <host> attribute's xmlNamespaceAware.
 boolean getTldValidation()
          Get the server.xml attribute's webXmlValidation.
 boolean getUseHttpOnly()
          Gets the value of the use HttpOnly cookies for session cookies flag.
 String getWebappVersion()
          Set the version of this web application - used to differentiate different versions of the same web application when using parallel deployment.
 String getWrapperClass()
          Return the Java class name of the Wrapper implementation used for servlets registered in this Context.
 boolean getXmlNamespaceAware()
          Get the server.xml attribute's xmlNamespaceAware.
 boolean getXmlValidation()
          Get the server.xml attribute's xmlValidation.
 boolean isResourceOnlyServlet(String servletName)
          Checks the named Servlet to see if it expects a resource to be present.
 boolean isServlet22()
          Is this context using version 2.2 of the Servlet spec?
 void reload()
          Reload this web application, if reloading is supported.
 void removeApplicationListener(String listener)
          Remove the specified application listener class from the set of listeners for this application.
 void removeApplicationParameter(String name)
          Remove the application parameter with the specified name from the set for this application.
 void removeConstraint(SecurityConstraint constraint)
          Remove the specified security constraint from this web application.
 void removeErrorPage(ErrorPage errorPage)
          Remove the error page for the specified error code or Java language exception, if it exists; otherwise, no action is taken.
 void removeFilterDef(FilterDef filterDef)
          Remove the specified filter definition from this Context, if it exists; otherwise, no action is taken.
 void removeFilterMap(FilterMap filterMap)
          Remove a filter mapping from this Context.
 void removeInstanceListener(String listener)
          Remove a class name from the set of InstanceListener classes that will be added to newly created Wrappers.
 void removeMimeMapping(String extension)
          Remove the MIME mapping for the specified extension, if it exists; otherwise, no action is taken.
 void removeParameter(String name)
          Remove the context initialization parameter with the specified name, if it exists; otherwise, no action is taken.
 void removeRoleMapping(String role)
          Remove any security role reference for the specified name
 void removeSecurityRole(String role)
          Remove any security role with the specified name.
 void removeServletMapping(String pattern)
          Remove any servlet mapping for the specified pattern, if it exists; otherwise, no action is taken.
 void removeWatchedResource(String name)
          Remove the specified watched resource name from the list associated with this Context.
 void removeWelcomeFile(String name)
          Remove the specified welcome file name from the list recognized by this Context.
 void removeWrapperLifecycle(String listener)
          Remove a class name from the set of LifecycleListener classes that will be added to newly created Wrappers.
 void removeWrapperListener(String listener)
          Remove a class name from the set of ContainerListener classes that will be added to newly created Wrappers.
 void setAllowCasualMultipartParsing(boolean allowCasualMultipartParsing)
          Set to true to allow requests mapped to servlets that do not explicitly declare @MultipartConfig or have <multipart-config> specified in web.xml to parse multipart/form-data requests.
 void setAltDDName(String altDDName)
          Set an alternate Deployment Descriptor name.
 void setApplicationEventListeners(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.
 void setApplicationLifecycleListeners(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.
 void setCharsetMapper(CharsetMapper mapper)
          Deprecated.  
 void setConfigFile(URL configFile)
          Set the URL of the XML descriptor for this context.
 void setConfigured(boolean configured)
          Set the "correctly configured" flag for this Context.
 void setCookies(boolean cookies)
          Set the "use cookies for session ids" flag.
 void setCrossContext(boolean crossContext)
          Set the "allow crossing servlet contexts" flag.
 void setDisplayName(String displayName)
          Set the display name of this web application.
 void setDistributable(boolean distributable)
          Set the distributable flag for this web application.
 void setDocBase(String docBase)
          Set the document root for this Context.
 void setEffectiveMajorVersion(int major)
          Set the effective major version of the Servlet spec used by this context.
 void setEffectiveMinorVersion(int minor)
          Set the effective minor version of the Servlet spec used by this context.
 void setFireRequestListenersOnForwards(boolean enable)
          Configure whether or not requests listeners will be fired on forwards for this Context.
 void setIgnoreAnnotations(boolean ignoreAnnotations)
          Set the boolean on the annotations parsing for this web application.
 void setJarScanner(JarScanner jarScanner)
          Set the Jar Scanner to be used to scan for JAR resources for this context.
 void setLogEffectiveWebXml(boolean logEffectiveWebXml)
          Set whether or not the effective web.xml for this context should be logged on context start.
 void setLoginConfig(LoginConfig config)
          Set the login configuration descriptor for this web application.
 void setNamingResources(NamingResources namingResources)
          Set the naming resources for this web application.
 void setOverride(boolean override)
          Set the override flag for this web application.
 void setPath(String path)
          Set the context path for this web application.
 void setPreemptiveAuthentication(boolean enable)
          Configures if a user presents authentication credentials, whether the context will process them when the request is for a non-protected resource.
 void setPrivileged(boolean privileged)
          Set the privileged flag for this web application.
 void setPublicId(String publicId)
          Set the public identifier of the deployment descriptor DTD that is currently being parsed.
 void setReloadable(boolean reloadable)
          Set the reloadable flag for this web application.
 void setResourceOnlyServlets(String resourceOnlyServlets)
          Sets the (comma separated) list of Servlets that expect a resource to be present.
 void setSendRedirectBody(boolean enable)
          Configures if a response body is included when a redirect response is sent to the client.
 void setSessionCookieDomain(String sessionCookieDomain)
          Sets the domain to use for session cookies.
 void setSessionCookieName(String sessionCookieName)
          Sets the name to use for session cookies.
 void setSessionCookiePath(String sessionCookiePath)
          Sets the path to use for session cookies.
 void setSessionCookiePathUsesTrailingSlash(boolean sessionCookiePathUsesTrailingSlash)
          Configures if a / is added to the end of the session cookie path to ensure browsers, particularly IE, don't send a session cookie for context /foo with requests intended for context /foobar.
 void setSessionTimeout(int timeout)
          Set the default session timeout (in minutes) for this web application.
 void setSwallowAbortedUploads(boolean swallowAbortedUploads)
          Set to false to disable request data swallowing after an upload was aborted due to size constraints.
 void setSwallowOutput(boolean swallowOutput)
          Set the value of the swallowOutput flag.
 void setTldNamespaceAware(boolean tldNamespaceAware)
          Set the namespace aware feature of the XML parser used when parsing xml instances.
 void setTldValidation(boolean tldValidation)
          Set the validation feature of the XML parser used when parsing tlds files.
 void setUseHttpOnly(boolean useHttpOnly)
          Sets the use HttpOnly cookies for session cookies flag.
 void setWebappVersion(String webappVersion)
          Set the version of this web application - used to differentiate different versions of the same web application when using parallel deployment.
 void setWrapperClass(String wrapperClass)
          Set the Java class name of the Wrapper implementation used for servlets registered in this Context.
 void setXmlNamespaceAware(boolean xmlNamespaceAware)
          Set the namespace aware feature of the XML parser used when parsing xml instances.
 void setXmlValidation(boolean xmlValidation)
          Set the validation feature of the XML parser used when parsing xml instances.
 
Methods inherited from interface org.apache.catalina.Container
addChild, addContainerListener, addPropertyChangeListener, backgroundProcess, findChild, findChildren, findContainerListeners, fireContainerEvent, getAccessLog, getBackgroundProcessorDelay, getCluster, getInfo, getLoader, getLogger, getManager, getMappingObject, getName, getObjectName, getParent, getParentClassLoader, getPipeline, getRealm, getResources, getStartStopThreads, invoke, logAccess, removeChild, removeContainerListener, removePropertyChangeListener, setBackgroundProcessorDelay, setCluster, setLoader, setManager, setName, setParent, setParentClassLoader, setRealm, setResources, setStartStopThreads
 
Methods inherited from interface org.apache.catalina.Lifecycle
addLifecycleListener, destroy, findLifecycleListeners, getState, getStateName, init, removeLifecycleListener, start, stop
 

Field Detail

RELOAD_EVENT

@Deprecated
static final String RELOAD_EVENT
Deprecated. Will be removed in Tomcat 8.0.x onwards.
The LifecycleEvent type sent when a context is reloaded.

See Also:
Constant Field Values

ADD_WELCOME_FILE_EVENT

static final String ADD_WELCOME_FILE_EVENT
Container event for adding a welcome file.

See Also:
Constant Field Values

REMOVE_WELCOME_FILE_EVENT

static final String REMOVE_WELCOME_FILE_EVENT
Container event for removing a wrapper.

See Also:
Constant Field Values

CLEAR_WELCOME_FILES_EVENT

static final String CLEAR_WELCOME_FILES_EVENT
Container event for clearing welcome files.

See Also:
Constant Field Values

CHANGE_SESSION_ID_EVENT

static final String CHANGE_SESSION_ID_EVENT
Container event for changing the ID of a session.

See Also:
Constant Field Values
Method Detail

getAllowCasualMultipartParsing

boolean getAllowCasualMultipartParsing()
Returns true if requests mapped to servlets without "multipart config" to parse multipart/form-data requests anyway.

Returns:
true if requests mapped to servlets without "multipart config" to parse multipart/form-data requests, false otherwise.

setAllowCasualMultipartParsing

void setAllowCasualMultipartParsing(boolean allowCasualMultipartParsing)
Set to true to allow requests mapped to servlets that do not explicitly declare @MultipartConfig or have <multipart-config> specified in web.xml to parse multipart/form-data requests.

Parameters:
allowCasualMultipartParsing - true to allow such casual parsing, false otherwise.

getApplicationEventListeners

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.

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

setApplicationEventListeners

void setApplicationEventListeners(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.

Parameters:
listeners - The set of instantiated listener objects.

getApplicationLifecycleListeners

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.

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

setApplicationLifecycleListeners

void setApplicationLifecycleListeners(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.

Parameters:
listeners - The set of instantiated listener objects.

getAvailable

boolean getAvailable()
Return the application available flag for this Context.


getCharsetMapper

@Deprecated
CharsetMapper getCharsetMapper()
Deprecated. Use getCharset(Locale)

Return the Locale to character set mapper for this Context.


setCharsetMapper

@Deprecated
void setCharsetMapper(CharsetMapper mapper)
Deprecated. 

Set the Locale to character set mapper for this Context.

Parameters:
mapper - The new mapper

getCharset

String getCharset(Locale locale)
Obtain the character set name to use with the given Locale. Note that different Contexts may have different mappings of Locale to character set.


getConfigFile

URL getConfigFile()
Return the URL of the XML descriptor for this context.


setConfigFile

void setConfigFile(URL configFile)
Set the URL of the XML descriptor for this context.

Parameters:
configFile - The URL of the XML descriptor for this context.

getConfigured

boolean getConfigured()
Return the "correctly configured" flag for this Context.


setConfigured

void setConfigured(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.

Parameters:
configured - The new correctly configured flag

getCookies

boolean getCookies()
Return the "use cookies for session ids" flag.


setCookies

void setCookies(boolean cookies)
Set the "use cookies for session ids" flag.

Parameters:
cookies - The new flag

getSessionCookieName

String getSessionCookieName()
Gets the name to use for session cookies. Overrides any setting that may be specified by the application.

Returns:
The value of the default session cookie name or null if not specified

setSessionCookieName

void setSessionCookieName(String sessionCookieName)
Sets the name to use for session cookies. Overrides any setting that may be specified by the application.

Parameters:
sessionCookieName - The name to use

getUseHttpOnly

boolean getUseHttpOnly()
Gets the value of the use HttpOnly cookies for session cookies flag.

Returns:
true if the HttpOnly flag should be set on session cookies

setUseHttpOnly

void setUseHttpOnly(boolean useHttpOnly)
Sets the use HttpOnly cookies for session cookies flag.

Parameters:
useHttpOnly - Set to true to use HttpOnly cookies for session cookies

getSessionCookieDomain

String getSessionCookieDomain()
Gets the domain to use for session cookies. Overrides any setting that may be specified by the application.

Returns:
The value of the default session cookie domain or null if not specified

setSessionCookieDomain

void setSessionCookieDomain(String sessionCookieDomain)
Sets the domain to use for session cookies. Overrides any setting that may be specified by the application.

Parameters:
sessionCookieDomain - The domain to use

getSessionCookiePath

String getSessionCookiePath()
Gets the path to use for session cookies. Overrides any setting that may be specified by the application.

Returns:
The value of the default session cookie path or null if not specified

setSessionCookiePath

void setSessionCookiePath(String sessionCookiePath)
Sets the path to use for session cookies. Overrides any setting that may be specified by the application.

Parameters:
sessionCookiePath - The path to use

getSessionCookiePathUsesTrailingSlash

boolean getSessionCookiePathUsesTrailingSlash()
Is a / added to the end of the session cookie path to ensure browsers, particularly IE, don't send a session cookie for context /foo with requests intended for context /foobar.

Returns:
true if the slash is added, otherwise false

setSessionCookiePathUsesTrailingSlash

void setSessionCookiePathUsesTrailingSlash(boolean sessionCookiePathUsesTrailingSlash)
Configures if a / is added to the end of the session cookie path to ensure browsers, particularly IE, don't send a session cookie for context /foo with requests intended for context /foobar.

Parameters:
sessionCookiePathUsesTrailingSlash - true if the slash is should be added, otherwise false

getCrossContext

boolean getCrossContext()
Return the "allow crossing servlet contexts" flag.


getAltDDName

String getAltDDName()
Return the alternate Deployment Descriptor name.


setAltDDName

void setAltDDName(String altDDName)
Set an alternate Deployment Descriptor name.


setCrossContext

void setCrossContext(boolean crossContext)
Set the "allow crossing servlet contexts" flag.

Parameters:
crossContext - The new cross contexts flag

getDisplayName

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


setDisplayName

void setDisplayName(String displayName)
Set the display name of this web application.

Parameters:
displayName - The new display name

getDistributable

boolean getDistributable()
Return the distributable flag for this web application.


setDistributable

void setDistributable(boolean distributable)
Set the distributable flag for this web application.

Parameters:
distributable - The new distributable flag

getDocBase

String getDocBase()
Return the document root for this Context. This can be an absolute pathname, a relative pathname, or a URL.


setDocBase

void setDocBase(String docBase)
Set the document root for this Context. This can be an absolute pathname, a relative pathname, or a URL.

Parameters:
docBase - The new document root

getEncodedPath

String getEncodedPath()
Return the URL encoded context path, using UTF-8.


getIgnoreAnnotations

boolean getIgnoreAnnotations()
Return the boolean on the annotations parsing.


setIgnoreAnnotations

void setIgnoreAnnotations(boolean ignoreAnnotations)
Set the boolean on the annotations parsing for this web application.

Parameters:
ignoreAnnotations - The boolean on the annotations parsing

getLoginConfig

LoginConfig getLoginConfig()
Return the login configuration descriptor for this web application.


setLoginConfig

void setLoginConfig(LoginConfig config)
Set the login configuration descriptor for this web application.

Parameters:
config - The new login configuration

getMapper

Mapper getMapper()
Get the request dispatcher mapper.


getNamingResources

NamingResources getNamingResources()
Return the naming resources associated with this web application.


setNamingResources

void setNamingResources(NamingResources namingResources)
Set the naming resources for this web application.

Parameters:
namingResources - The new naming resources

getPath

String getPath()
Return the context path for this web application.


setPath

void setPath(String path)
Set the context path for this web application.

Parameters:
path - The new context path

getPublicId

String getPublicId()
Return the public identifier of the deployment descriptor DTD that is currently being parsed.


setPublicId

void setPublicId(String publicId)
Set the public identifier of the deployment descriptor DTD that is currently being parsed.

Parameters:
publicId - The public identifier

getReloadable

boolean getReloadable()
Return the reloadable flag for this web application.


setReloadable

void setReloadable(boolean reloadable)
Set the reloadable flag for this web application.

Parameters:
reloadable - The new reloadable flag

getOverride

boolean getOverride()
Return the override flag for this web application.


setOverride

void setOverride(boolean override)
Set the override flag for this web application.

Parameters:
override - The new override flag

getPrivileged

boolean getPrivileged()
Return the privileged flag for this web application.


setPrivileged

void setPrivileged(boolean privileged)
Set the privileged flag for this web application.

Parameters:
privileged - The new privileged flag

getServletContext

ServletContext getServletContext()
Return the servlet context for which this Context is a facade.


getSessionTimeout

int getSessionTimeout()
Return the default session timeout (in minutes) for this web application.


setSessionTimeout

void setSessionTimeout(int timeout)
Set the default session timeout (in minutes) for this web application.

Parameters:
timeout - The new default session timeout

getSwallowAbortedUploads

boolean getSwallowAbortedUploads()
Returns true if remaining request data will be read (swallowed) even the request violates a data size constraint.

Returns:
true if data will be swallowed (default), false otherwise.

setSwallowAbortedUploads

void setSwallowAbortedUploads(boolean swallowAbortedUploads)
Set to false to disable request data swallowing after an upload was aborted due to size constraints.

Parameters:
swallowAbortedUploads - false to disable swallowing, true otherwise (default).

getSwallowOutput

boolean getSwallowOutput()
Return the value of the swallowOutput flag.


setSwallowOutput

void setSwallowOutput(boolean swallowOutput)
Set the value of the swallowOutput flag. If set to true, the system.out and system.err will be redirected to the logger during a servlet execution.

Parameters:
swallowOutput - The new value

getWrapperClass

String getWrapperClass()
Return the Java class name of the Wrapper implementation used for servlets registered in this Context.


setWrapperClass

void setWrapperClass(String wrapperClass)
Set the Java class name of the Wrapper implementation used for servlets registered in this Context.

Parameters:
wrapperClass - The new wrapper class

getXmlNamespaceAware

boolean getXmlNamespaceAware()
Get the server.xml attribute's xmlNamespaceAware.

Returns:
true if namespace awareness is enabled.

getXmlValidation

boolean getXmlValidation()
Get the server.xml attribute's xmlValidation.

Returns:
true if validation is enabled.

setXmlValidation

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

Parameters:
xmlValidation - true to enable xml instance validation

setXmlNamespaceAware

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

Parameters:
xmlNamespaceAware - true to enable namespace awareness

setTldValidation

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

Parameters:
tldValidation - true to enable xml instance validation

getTldValidation

boolean getTldValidation()
Get the server.xml attribute's webXmlValidation.

Returns:
true if validation is enabled.

getTldNamespaceAware

boolean getTldNamespaceAware()
Get the server.xml <host> attribute's xmlNamespaceAware.

Returns:
true if namespace awareness is enabled.

setTldNamespaceAware

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

Parameters:
tldNamespaceAware - true to enable namespace awareness

getJarScanner

JarScanner getJarScanner()
Get the Jar Scanner to be used to scan for JAR resources for this context.

Returns:
The Jar Scanner configured for this context.

setJarScanner

void setJarScanner(JarScanner jarScanner)
Set the Jar Scanner to be used to scan for JAR resources for this context.

Parameters:
jarScanner - The Jar Scanner to be used for this context.

getAuthenticator

Authenticator getAuthenticator()
Obtain the Authenticator that is used by this context or null if none is used.


setLogEffectiveWebXml

void setLogEffectiveWebXml(boolean logEffectiveWebXml)
Set whether or not the effective web.xml for this context should be logged on context start.


getLogEffectiveWebXml

boolean getLogEffectiveWebXml()
Should the effective web.xml for this context be logged on context start?


addApplicationListener

void addApplicationListener(String listener)
Add a new Listener class name to the set of Listeners configured for this application.

Parameters:
listener - Java class name of a listener class

addApplicationParameter

void addApplicationParameter(ApplicationParameter parameter)
Add a new application parameter for this application.

Parameters:
parameter - The new application parameter

addConstraint

void addConstraint(SecurityConstraint constraint)
Add a security constraint to the set for this web application.


addErrorPage

void addErrorPage(ErrorPage errorPage)
Add an error page for the specified error or Java exception.

Parameters:
errorPage - The error page definition to be added

addFilterDef

void addFilterDef(FilterDef filterDef)
Add a filter definition to this Context.

Parameters:
filterDef - The filter definition to be added

addFilterMap

void addFilterMap(FilterMap filterMap)
Add a filter mapping to this Context.

Parameters:
filterMap - The filter mapping to be added

addFilterMapBefore

void addFilterMapBefore(FilterMap filterMap)
Add a filter mapping to this Context before the mappings defined in the deployment descriptor but after any other mappings added via this method.

Parameters:
filterMap - The filter mapping to be added
Throws:
IllegalArgumentException - if the specified filter name does not match an existing filter definition, or the filter mapping is malformed

addInstanceListener

void addInstanceListener(String listener)
Add the classname of an InstanceListener to be added to each Wrapper appended to this Context.

Parameters:
listener - Java class name of an InstanceListener class

addLocaleEncodingMappingParameter

void addLocaleEncodingMappingParameter(String locale,
                                       String encoding)
Add a Locale Encoding Mapping (see Sec 5.4 of Servlet spec 2.4)

Parameters:
locale - locale to map an encoding for
encoding - encoding to be used for a give locale

addMimeMapping

void addMimeMapping(String extension,
                    String mimeType)
Add a new MIME mapping, replacing any existing mapping for the specified extension.

Parameters:
extension - Filename extension being mapped
mimeType - Corresponding MIME type

addParameter

void addParameter(String name,
                  String value)
Add a new context initialization parameter, replacing any existing value for the specified name.

Parameters:
name - Name of the new parameter
value - Value of the new parameter

addRoleMapping

void addRoleMapping(String role,
                    String link)
Add a security role reference for this web application.

Parameters:
role - Security role used in the application
link - Actual security role to check for

addSecurityRole

void addSecurityRole(String role)
Add a new security role for this web application.

Parameters:
role - New security role

addServletMapping

void addServletMapping(String pattern,
                       String name)
Add a new servlet mapping, replacing any existing mapping for the specified pattern.

Parameters:
pattern - URL pattern to be mapped
name - Name of the corresponding servlet to execute

addServletMapping

void addServletMapping(String pattern,
                       String name,
                       boolean jspWildcard)
Add a new servlet mapping, replacing any existing mapping for the specified pattern.

Parameters:
pattern - URL pattern to be mapped
name - Name of the corresponding servlet to execute
jspWildcard - true if name identifies the JspServlet and pattern contains a wildcard; false otherwise

addWatchedResource

void addWatchedResource(String name)
Add a resource which will be watched for reloading by the host auto deployer. Note: this will not be used in embedded mode.

Parameters:
name - Path to the resource, relative to docBase

addWelcomeFile

void addWelcomeFile(String name)
Add a new welcome file to the set recognized by this Context.

Parameters:
name - New welcome file name

addWrapperLifecycle

void addWrapperLifecycle(String listener)
Add the classname of a LifecycleListener to be added to each Wrapper appended to this Context.

Parameters:
listener - Java class name of a LifecycleListener class

addWrapperListener

void addWrapperListener(String listener)
Add the classname of a ContainerListener to be added to each Wrapper appended to this Context.

Parameters:
listener - Java class name of a ContainerListener class

createWrapper

Wrapper createWrapper()
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.


findApplicationListeners

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


findApplicationParameters

ApplicationParameter[] findApplicationParameters()
Return the set of application parameters for this application.


findConstraints

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


findErrorPage

ErrorPage findErrorPage(int errorCode)
Return the error page entry for the specified HTTP error code, if any; otherwise return null.

Parameters:
errorCode - Error code to look up

findErrorPage

ErrorPage findErrorPage(String exceptionType)
Return the error page entry for the specified Java exception type, if any; otherwise return null.

Parameters:
exceptionType - Exception type to look up

findErrorPages

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


findFilterDef

FilterDef findFilterDef(String filterName)
Return the filter definition for the specified filter name, if any; otherwise return null.

Parameters:
filterName - Filter name to look up

findFilterDefs

FilterDef[] findFilterDefs()
Return the set of defined filters for this Context.


findFilterMaps

FilterMap[] findFilterMaps()
Return the set of filter mappings for this Context.


findInstanceListeners

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


findMimeMapping

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

Parameters:
extension - Extension to map to a MIME type

findMimeMappings

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


findParameter

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

Parameters:
name - Name of the parameter to return

findParameters

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.


findRoleMapping

String findRoleMapping(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.

Parameters:
role - Security role to map

findSecurityRole

boolean findSecurityRole(String role)
Return true if the specified security role is defined for this application; otherwise return false.

Parameters:
role - Security role to verify

findSecurityRoles

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


findServletMapping

String findServletMapping(String pattern)
Return the servlet name mapped by the specified pattern (if any); otherwise return null.

Parameters:
pattern - Pattern for which a mapping is requested

findServletMappings

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


findStatusPage

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

Parameters:
status - HTTP status code to look up

findStatusPages

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.


findWatchedResources

String[] findWatchedResources()
Return the set of watched resources for this Context. If none are defined, a zero length array will be returned.


findWelcomeFile

boolean findWelcomeFile(String name)
Return true if the specified welcome file is defined for this Context; otherwise return false.

Parameters:
name - Welcome file to verify

findWelcomeFiles

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


findWrapperLifecycles

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


findWrapperListeners

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


fireRequestInitEvent

boolean fireRequestInitEvent(ServletRequest request)
Notify all ServletRequestListeners that a request has started.

Returns:
true if the listeners fire successfully, else false

fireRequestDestroyEvent

boolean fireRequestDestroyEvent(ServletRequest request)
Notify all ServletRequestListeners that a request has ended.

Returns:
true if the listeners fire successfully, else false

reload

void reload()
Reload this web application, if reloading is supported.

Throws:
IllegalStateException - if the reloadable property is set to false.

removeApplicationListener

void removeApplicationListener(String listener)
Remove the specified application listener class from the set of listeners for this application.

Parameters:
listener - Java class name of the listener to be removed

removeApplicationParameter

void removeApplicationParameter(String name)
Remove the application parameter with the specified name from the set for this application.

Parameters:
name - Name of the application parameter to remove

removeConstraint

void removeConstraint(SecurityConstraint constraint)
Remove the specified security constraint from this web application.

Parameters:
constraint - Constraint to be removed

removeErrorPage

void removeErrorPage(ErrorPage errorPage)
Remove the error page for the specified error code or Java language exception, if it exists; otherwise, no action is taken.

Parameters:
errorPage - The error page definition to be removed

removeFilterDef

void removeFilterDef(FilterDef filterDef)
Remove the specified filter definition from this Context, if it exists; otherwise, no action is taken.

Parameters:
filterDef - Filter definition to be removed

removeFilterMap

void removeFilterMap(FilterMap filterMap)
Remove a filter mapping from this Context.

Parameters:
filterMap - The filter mapping to be removed

removeInstanceListener

void removeInstanceListener(String listener)
Remove a class name from the set of InstanceListener classes that will be added to newly created Wrappers.

Parameters:
listener - Class name of an InstanceListener class to be removed

removeMimeMapping

void removeMimeMapping(String extension)
Remove the MIME mapping for the specified extension, if it exists; otherwise, no action is taken.

Parameters:
extension - Extension to remove the mapping for

removeParameter

void removeParameter(String name)
Remove the context initialization parameter with the specified name, if it exists; otherwise, no action is taken.

Parameters:
name - Name of the parameter to remove

removeRoleMapping

void removeRoleMapping(String role)
Remove any security role reference for the specified name

Parameters:
role - Security role (as used in the application) to remove

removeSecurityRole

void removeSecurityRole(String role)
Remove any security role with the specified name.

Parameters:
role - Security role to remove

removeServletMapping

void removeServletMapping(String pattern)
Remove any servlet mapping for the specified pattern, if it exists; otherwise, no action is taken.

Parameters:
pattern - URL pattern of the mapping to remove

removeWatchedResource

void removeWatchedResource(String name)
Remove the specified watched resource name from the list associated with this Context.

Parameters:
name - Name of the watched resource to be removed

removeWelcomeFile

void removeWelcomeFile(String name)
Remove the specified welcome file name from the list recognized by this Context.

Parameters:
name - Name of the welcome file to be removed

removeWrapperLifecycle

void removeWrapperLifecycle(String listener)
Remove a class name from the set of LifecycleListener classes that will be added to newly created Wrappers.

Parameters:
listener - Class name of a LifecycleListener class to be removed

removeWrapperListener

void removeWrapperListener(String listener)
Remove a class name from the set of ContainerListener classes that will be added to newly created Wrappers.

Parameters:
listener - Class name of a ContainerListener class to be removed

getRealPath

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

getEffectiveMajorVersion

int getEffectiveMajorVersion()
Return the effective major version of the Servlet spec used by this context.


setEffectiveMajorVersion

void setEffectiveMajorVersion(int major)
Set the effective major version of the Servlet spec used by this context.


getEffectiveMinorVersion

int getEffectiveMinorVersion()
Return the effective minor version of the Servlet spec used by this context.


setEffectiveMinorVersion

void setEffectiveMinorVersion(int minor)
Set the effective minor version of the Servlet spec used by this context.


getJspConfigDescriptor

JspConfigDescriptor getJspConfigDescriptor()
Obtain the JSP configuration for this context.


addResourceJarUrl

void addResourceJarUrl(URL url)
Add a URL for a JAR that contains static resources in a META-INF/resources directory that should be included in the static resources for this context.


addServletContainerInitializer

void addServletContainerInitializer(ServletContainerInitializer sci,
                                    Set<Class<?>> classes)
Add a ServletContainerInitializer instance to this web application.

Parameters:
sci - The instance to add
classes - The classes in which the initializer expressed an interest

getPaused

boolean getPaused()
Is this Context paused whilst it is reloaded?


isServlet22

boolean isServlet22()
Is this context using version 2.2 of the Servlet spec?


addServletSecurity

Set<String> addServletSecurity(ApplicationServletRegistration registration,
                               ServletSecurityElement servletSecurityElement)
Notification that servlet security has been dynamically set in a ServletRegistration.Dynamic

Parameters:
registration - servlet security was modified for
servletSecurityElement - new security constraints for this servlet
Returns:
urls currently mapped to this registration that are already present in web.xml

setResourceOnlyServlets

void setResourceOnlyServlets(String resourceOnlyServlets)
Sets the (comma separated) list of Servlets that expect a resource to be present. Used to ensure that welcome files associated with Servlets that expect a resource to be present are not mapped when there is no resource.


getResourceOnlyServlets

String getResourceOnlyServlets()
Obtains the list of Servlets that expect a resource to be present.

Returns:
A comma separated list of Servlet names as used in web.xml

isResourceOnlyServlet

boolean isResourceOnlyServlet(String servletName)
Checks the named Servlet to see if it expects a resource to be present.

Parameters:
servletName - Name of the Servlet (as per web.xml) to check
Returns:
true if the Servlet expects a resource, otherwise false

getBaseName

String getBaseName()
Return the base name to use for WARs, directories or context.xml files for this context.


setWebappVersion

void setWebappVersion(String webappVersion)
Set the version of this web application - used to differentiate different versions of the same web application when using parallel deployment.


getWebappVersion

String getWebappVersion()
Set the version of this web application - used to differentiate different versions of the same web application when using parallel deployment. If not specified, defaults to the empty string.


setFireRequestListenersOnForwards

void setFireRequestListenersOnForwards(boolean enable)
Configure whether or not requests listeners will be fired on forwards for this Context.


getFireRequestListenersOnForwards

boolean getFireRequestListenersOnForwards()
Determine whether or not requests listeners will be fired on forwards for this Context.


setPreemptiveAuthentication

void setPreemptiveAuthentication(boolean enable)
Configures if a user presents authentication credentials, whether the context will process them when the request is for a non-protected resource.


getPreemptiveAuthentication

boolean getPreemptiveAuthentication()
Determines if a user presents authentication credentials, will the context will process them when the request is for a non-protected resource.


setSendRedirectBody

void setSendRedirectBody(boolean enable)
Configures if a response body is included when a redirect response is sent to the client.


getSendRedirectBody

boolean getSendRedirectBody()
Determines if the context is configured to include a response body as part of a redirect response.


Apache Tomcat 7.0.28

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