Interface Context
- All Superinterfaces:
Container
,ContextBind
,Lifecycle
- All Known Implementing Classes:
FailedContext
,ReplicatedContext
,StandardContext
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
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.catalina.Lifecycle
Lifecycle.SingleUse
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Container event for adding a welcome file.static final String
Container event for changing the ID of a session.static final String
Container event for clearing welcome files.static final String
Container event for removing a wrapper.static final String
Prefix for resource lookup.Fields inherited from interface org.apache.catalina.Container
ADD_CHILD_EVENT, ADD_VALVE_EVENT, REMOVE_CHILD_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
Modifier and TypeMethodDescriptionvoid
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
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
addPostConstructMethod
(String clazz, String method) Add a post construct method definition for the given class, if there is an existing definition for the specified class - IllegalArgumentException will be thrown.void
addPreDestroyMethod
(String clazz, String method) Add a pre destroy method definition for the given class, if there is an existing definition for the specified class - IllegalArgumentException will be thrown.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.default void
addServletMappingDecoded
(String pattern, String name) Add a new servlet mapping, replacing any existing mapping for the specified pattern.void
addServletMappingDecoded
(String pattern, String name, boolean jspWildcard) Add a new servlet mapping, replacing any existing mapping for the specified pattern.addServletSecurity
(ServletRegistration.Dynamic registration, ServletSecurityElement servletSecurityElement) Notification that Servlet security has been dynamically set in aServletRegistration.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.Factory method to create and return a new InstanceManager instance.Factory method to create and return a new Wrapper instance, of the Java implementation class appropriate for this Context implementation.void
String[]
default ConfigurationSource.Resource
findConfigFileResource
(String name) Find configuration file with the specified path, first looking into the webapp resources, then delegating toConfigFileLoader.getSource().getResource
.findErrorPage
(int errorCode) findErrorPage
(Throwable throwable) Find and return the ErrorPage instance for the specified exception's class, or an ErrorPage instance for the closest superclass for which there is such a definition.findFilterDef
(String filterName) findMimeMapping
(String extension) String[]
findParameter
(String name) String[]
findPostConstructMethod
(String clazz) Returns the method name that is specified as post construct method for the given class, if it exists; otherwiseNULL
will be returned.Returns a map with keys - fully qualified class names of the classes that have post construct methods and the values are the corresponding method names.findPreDestroyMethod
(String clazz) Returns the method name that is specified as pre destroy method for the given class, if it exists; otherwiseNULL
will be returned.Returns a map with keys - fully qualified class names of the classes that have pre destroy methods and the values are the corresponding method names.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) String[]
findServletMapping
(String pattern) String[]
String[]
boolean
findWelcomeFile
(String name) String[]
String[]
String[]
boolean
fireRequestDestroyEvent
(ServletRequest request) Notify allServletRequestListener
s that a request has ended.boolean
fireRequestInitEvent
(ServletRequest request) Notify allServletRequestListener
s that a request has started.boolean
boolean
Returnstrue
if requests mapped to servlets without "multipart config" to parse multipart/form-data requests anyway.boolean
When returning a context path fromHttpServletRequest.getContextPath()
, is it allowed to contain multiple leading '/' characters?Return the alternate Deployment Descriptor name.boolean
If this istrue
, every request that is associated with a session will cause the session's last accessed time to be updated regardless of whether or not the request explicitly accesses the session.Object[]
Obtain the registered application event listeners.Object[]
Obtain the registered application lifecycle listeners.getCharset
(Locale locale) Obtain the character set name to use with the given Locale.Return the URL of the XML descriptor for this context.boolean
Return the "correctly configured" flag for this Context.Obtains the regular expression that specifies which container provided SCIs should be filtered out and not used for this context.boolean
If this istrue
then the path passed toServletContext.getResource()
orServletContext.getResourceAsStream()
must start with "/".boolean
Return the "use cookies for session ids" flag.boolean
Will Tomcat attempt to create an upload target used by this web application if it does not exist when the web application attempts to use it?boolean
Return the "allow crossing servlet contexts" flag.boolean
Return the deny-uncovered-http-methods flag for this web application.boolean
Are paths used in calls to obtain a request dispatcher expected to be encoded?boolean
If this istrue
then any wrapped request or response object passed to an application dispatcher will be checked to ensure that it has wrapped the original request or response.Return the display name of this web application.boolean
Get the distributable flag for this web application.Obtain the document root for this Context.int
int
Return the URL encoded context pathboolean
boolean
Determine if annotations parsing is currently disabledGet the Jar Scanner to be used to scan for JAR resources for this context.boolean
Should the effective web.xml for this context be logged on context start?boolean
Determines if requests for a web application context root will be redirected (adding a trailing slash) by the Mapper.boolean
Determines if requests for a directory will be redirected (adding a trailing slash) by the Mapper.boolean
Determine if the metadata of the application is complete.boolean
boolean
getPath()
boolean
Is this Context paused whilst it is reloaded?boolean
boolean
getRealPath
(String path) boolean
Get the default request body encoding for this web application.Obtains the list of Servlets that expect a resource to be present.Get the default response body encoding for this web application.boolean
Gets the domain to use for session cookies.Gets the name to use for session cookies.Gets the path to use for session cookies.boolean
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
boolean
If this istrue
, then following a forward the response will be unwrapped to suspend the Catalina response instead of simply closing the top level response.boolean
Returnstrue
if remaining request data will be read (swallowed) even the request violates a data size constraint.boolean
boolean
Will the parsing of *.tld files for this Context be performed by a validating parser?boolean
Gets the value of the use HttpOnly cookies for session cookies flag.boolean
Should thePartitioned
attribute be added to session cookies created for this web application.boolean
Will HTTP 1.1 and later location headers generated by a call toHttpServletResponse.sendRedirect(String)
use relative or absolute redirects.boolean
Will client provided session IDs be validated (seesetValidateClientProvidedNewSessionId(boolean)
) before use?boolean
Will the parsing of web.xml, web-fragment.xml, *.tld, *.jspx, *.tagx and tagplugin.xml files for this Context block the use of external entities?boolean
Will the parsing of web.xml and web-fragment.xml files for this Context be performed by a namespace aware parser?boolean
Will the parsing of web.xml and web-fragment.xml files for this Context be performed by a validating parser?void
boolean
isResourceOnlyServlet
(String servletName) Checks the named Servlet to see if it expects a resource to be present.boolean
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
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
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
removePostConstructMethod
(String clazz) Removes the post construct method definition for the given class, if it exists; otherwise, no action is taken.void
removePreDestroyMethod
(String clazz) Removes the pre destroy method definition for the given class, if it exists; otherwise, no action is taken.void
removeRoleMapping
(String role) Remove any security role reference for the specified namevoid
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
setAddWebinfClassesResources
(boolean addWebinfClassesResources) Sets the flag that indicates if /WEB-INF/classes should be treated like an exploded JAR and JAR resources made available as if they were in a JAR.void
setAllowCasualMultipartParsing
(boolean allowCasualMultipartParsing) Set totrue
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
setAllowMultipleLeadingForwardSlashInPath
(boolean allowMultipleLeadingForwardSlashInPath) Configure if, when returning a context path fromHttpServletRequest.getContextPath()
, the return value is allowed to contain multiple leading '/' characters.void
setAltDDName
(String altDDName) Set an alternate Deployment Descriptor name.void
setAlwaysAccessSession
(boolean alwaysAccessSession) Set the session access behavior.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
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
setContainerSciFilter
(String containerSciFilter) Sets the regular expression that specifies which container provided SCIs should be filtered out and not used for this context.void
setContextGetResourceRequiresSlash
(boolean contextGetResourceRequiresSlash) Allow usingServletContext.getResource()
orServletContext.getResourceAsStream()
without a leading "/".void
setCookieProcessor
(CookieProcessor cookieProcessor) Sets theCookieProcessor
that will be used to process cookies for this Context.void
setCookies
(boolean cookies) Set the "use cookies for session ids" flag.void
setCreateUploadTargets
(boolean createUploadTargets) Configure whether Tomcat will attempt to create an upload target used by this web application if it does not exist when the web application attempts to use it.void
setCrossContext
(boolean crossContext) Set the "allow crossing servlet contexts" flag.void
setDenyUncoveredHttpMethods
(boolean denyUncoveredHttpMethods) Set the deny-uncovered-http-methods flag for this web application.void
setDispatchersUseEncodedPaths
(boolean dispatchersUseEncodedPaths) Are paths used in calls to obtain a request dispatcher expected to be encoded?void
setDispatcherWrapsSameObject
(boolean dispatcherWrapsSameObject) Allow disabling the object wrap check in the request dispatcher.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
setInstanceManager
(InstanceManager instanceManager) Set the instance manager associated with this context.void
setJarScanner
(JarScanner jarScanner) Set the Jar Scanner to be used to scan for JAR resources for this context.void
setJspConfigDescriptor
(JspConfigDescriptor descriptor) Set the JspConfigDescriptor for this context.void
Set the Loader with which this Context is associated.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
setManager
(Manager manager) Set the Manager with which this Context is associated.void
setMapperContextRootRedirectEnabled
(boolean mapperContextRootRedirectEnabled) If enabled, requests for a web application context root will be redirected (adding a trailing slash) by the Mapper.void
setMapperDirectoryRedirectEnabled
(boolean mapperDirectoryRedirectEnabled) If enabled, requests for a directory will be redirected (adding a trailing slash) by the Mapper.void
setMetadataComplete
(boolean metadataComplete) Set the boolean on the metadata complete flag for this web application.void
setNamingResources
(NamingResourcesImpl namingResources) Set the naming resources for this web application.void
setOverride
(boolean override) Set the override flag for this web application.void
setParallelAnnotationScanning
(boolean parallelAnnotationScanning) Set the parallel annotation scanning value.void
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
setRequestCharacterEncoding
(String encoding) Set the default request body encoding for this web application.void
setResourceOnlyServlets
(String resourceOnlyServlets) Sets the (comma separated) list of Servlets that expect a resource to be present.void
setResources
(WebResourceRoot resources) Set the Resources object with which this Context is associated.void
setResponseCharacterEncoding
(String encoding) Set the default response body encoding for this web application.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
setSuspendWrappedResponseAfterForward
(boolean suspendWrappedResponseAfterForward) Allows unwrapping the response object to suspend the response following a forward.void
setSwallowAbortedUploads
(boolean swallowAbortedUploads) Set tofalse
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
setThreadBindingListener
(ThreadBindingListener threadBindingListener) Get the associated ThreadBindingListener.void
setTldValidation
(boolean tldValidation) Controls whether the parsing of *.tld files for this Context will be performed by a validating parser.void
setUseHttpOnly
(boolean useHttpOnly) Sets the use HttpOnly cookies for session cookies flag.void
setUsePartitioned
(boolean usePartitioned) Configure whether thePartitioned
attribute should be added to session cookies created for this web application.void
setUseRelativeRedirects
(boolean useRelativeRedirects) Controls whether HTTP 1.1 and later location headers generated by a call toHttpServletResponse.sendRedirect(String)
will use relative or absolute redirects.void
setValidateClientProvidedNewSessionId
(boolean validateClientProvidedNewSessionId) When a client provides the ID for a new session, should that ID be validated?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
setXmlBlockExternal
(boolean xmlBlockExternal) Controls whether the parsing of web.xml, web-fragment.xml, *.tld, *.jspx, *.tagx and tagplugin.xml files for this Context will block the use of external entities.void
setXmlNamespaceAware
(boolean xmlNamespaceAware) Controls whether the parsing of web.xml and web-fragment.xml files for this Context will be performed by a namespace aware parser.void
setXmlValidation
(boolean xmlValidation) Controls whether the parsing of web.xml and web-fragment.xml files for this Context will be performed by a validating parser.Methods inherited from interface org.apache.catalina.Container
addChild, addContainerListener, addPropertyChangeListener, backgroundProcess, findChild, findChildren, findContainerListeners, fireContainerEvent, getAccessLog, getBackgroundProcessorDelay, getCatalinaBase, getCatalinaHome, getCluster, getDomain, getLogger, getLogName, getMBeanKeyProperties, getName, getObjectName, getParent, getParentClassLoader, getPipeline, getRealm, getStartStopThreads, logAccess, removeChild, removeContainerListener, removePropertyChangeListener, setBackgroundProcessorDelay, setCluster, setName, setParent, setParentClassLoader, setRealm, setStartStopThreads
Methods inherited from interface org.apache.tomcat.ContextBind
bind, bind, unbind, unbind
Methods inherited from interface org.apache.catalina.Lifecycle
addLifecycleListener, destroy, findLifecycleListeners, getState, getStateName, init, removeLifecycleListener, start, stop
-
Field Details
-
ADD_WELCOME_FILE_EVENT
-
REMOVE_WELCOME_FILE_EVENT
-
CLEAR_WELCOME_FILES_EVENT
-
CHANGE_SESSION_ID_EVENT
Container event for changing the ID of a session.- See Also:
-
WEBAPP_PROTOCOL
-
-
Method Details
-
getAllowCasualMultipartParsing
boolean getAllowCasualMultipartParsing()Returnstrue
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 totrue
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()Obtain the registered application event listeners.- Returns:
- An array containing the application event listener instances for this web application in the order they were specified in the web application deployment descriptor
-
setApplicationEventListeners
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()Obtain the registered application lifecycle listeners.- Returns:
- An array containing the application lifecycle listener instances for this web application in the order they were specified in the web application deployment descriptor
-
setApplicationLifecycleListeners
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.
-
getCharset
Obtain the character set name to use with the given Locale. Note that different Contexts may have different mappings of Locale to character set.- Parameters:
locale
- The locale for which the mapped character set should be returned- Returns:
- The name of the character set to use with the given Locale
-
getConfigFile
URL getConfigFile()Return the URL of the XML descriptor for this context.- Returns:
- The URL of the XML descriptor for this context
-
setConfigFile
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.- Returns:
true
if the Context has been correctly configured, otherwisefalse
-
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.- Returns:
true
if it is permitted to use cookies to track session IDs for this web application, otherwisefalse
-
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
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 totrue
to use HttpOnly cookies for session cookies
-
getUsePartitioned
boolean getUsePartitioned()Should thePartitioned
attribute be added to session cookies created for this web application.The name of the attribute used to indicate a partitioned cookie as part of CHIPS is not defined by an RFC and may change in a non-backwards compatible way once equivalent functionality is included in an RFC.
- Returns:
true
if thePartitioned
attribute should be added to session cookies created for this web application, otherwisefalse
-
setUsePartitioned
void setUsePartitioned(boolean usePartitioned) Configure whether thePartitioned
attribute should be added to session cookies created for this web application.The name of the attribute used to indicate a partitioned cookie as part of CHIPS is not defined by an RFC and may change in a non-backwards compatible way once equivalent functionality is included in an RFC.
- Parameters:
usePartitioned
-true
if thePartitioned
attribute should be added to session cookies created for this web application, otherwisefalse
-
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
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
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, otherwisefalse
-
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, otherwisefalse
-
getCrossContext
boolean getCrossContext()Return the "allow crossing servlet contexts" flag.- Returns:
true
if cross-contest requests are allowed from this web applications, otherwisefalse
-
getAltDDName
-
setAltDDName
Set an alternate Deployment Descriptor name.- Parameters:
altDDName
- The new name
-
setCrossContext
void setCrossContext(boolean crossContext) Set the "allow crossing servlet contexts" flag.- Parameters:
crossContext
- The new cross contexts flag
-
getDenyUncoveredHttpMethods
boolean getDenyUncoveredHttpMethods()Return the deny-uncovered-http-methods flag for this web application.- Returns:
- The current value of the flag
-
setDenyUncoveredHttpMethods
void setDenyUncoveredHttpMethods(boolean denyUncoveredHttpMethods) Set the deny-uncovered-http-methods flag for this web application.- Parameters:
denyUncoveredHttpMethods
- The new deny-uncovered-http-methods flag
-
getDisplayName
-
setDisplayName
Set the display name of this web application.- Parameters:
displayName
- The new display name
-
getDistributable
boolean getDistributable()Get the distributable flag for this web application.- Returns:
- The value of 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()Obtain the document root for this Context.- Returns:
- An absolute pathname or a relative (to the Host's appBase) pathname.
-
setDocBase
Set the document root for this Context. This can be either an absolute pathname or a relative pathname. Relative pathnames are relative to the containing Host's appBase.- Parameters:
docBase
- The new document root
-
getEncodedPath
String getEncodedPath()Return the URL encoded context path- Returns:
- The URL encoded (with UTF-8) context path
-
getIgnoreAnnotations
boolean getIgnoreAnnotations()Determine if annotations parsing is currently disabled- Returns:
true
if annotation parsing is disabled for this web application
-
setIgnoreAnnotations
void setIgnoreAnnotations(boolean ignoreAnnotations) Set the boolean on the annotations parsing for this web application.- Parameters:
ignoreAnnotations
- The boolean on the annotations parsing
-
getMetadataComplete
boolean getMetadataComplete()Determine if the metadata of the application is complete. This typically means annotations which add to the application metadata will be ignored.- Returns:
true
if metadata is complete for this web application
-
setMetadataComplete
void setMetadataComplete(boolean metadataComplete) Set the boolean on the metadata complete flag for this web application.- Parameters:
metadataComplete
- The boolean on the metadata complete flag
-
getLoginConfig
LoginConfig getLoginConfig()- Returns:
- the login configuration descriptor for this web application.
-
setLoginConfig
Set the login configuration descriptor for this web application.- Parameters:
config
- The new login configuration
-
getNamingResources
NamingResourcesImpl getNamingResources()- Returns:
- the naming resources associated with this web application.
-
setNamingResources
Set the naming resources for this web application.- Parameters:
namingResources
- The new naming resources
-
getPath
String getPath()- Returns:
- the context path for this web application.
-
setPath
Set the context path for this web application.- Parameters:
path
- The new context path
-
getPublicId
String getPublicId()- Returns:
- the public identifier of the deployment descriptor DTD that is currently being parsed.
-
setPublicId
Set the public identifier of the deployment descriptor DTD that is currently being parsed.- Parameters:
publicId
- The public identifier
-
getReloadable
boolean getReloadable()- Returns:
- 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()- Returns:
- 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()- Returns:
- 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()- Returns:
- the Servlet context for which this Context is a facade.
-
getSessionTimeout
int getSessionTimeout()- Returns:
- 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()Returnstrue
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 tofalse
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()- Returns:
- 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()- Returns:
- the Java class name of the Wrapper implementation used for servlets registered in this Context.
-
setWrapperClass
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()Will the parsing of web.xml and web-fragment.xml files for this Context be performed by a namespace aware parser?- Returns:
- true if namespace awareness is enabled.
-
setXmlNamespaceAware
void setXmlNamespaceAware(boolean xmlNamespaceAware) Controls whether the parsing of web.xml and web-fragment.xml files for this Context will be performed by a namespace aware parser.- Parameters:
xmlNamespaceAware
- true to enable namespace awareness
-
getXmlValidation
boolean getXmlValidation()Will the parsing of web.xml and web-fragment.xml files for this Context be performed by a validating parser?- Returns:
- true if validation is enabled.
-
setXmlValidation
void setXmlValidation(boolean xmlValidation) Controls whether the parsing of web.xml and web-fragment.xml files for this Context will be performed by a validating parser.- Parameters:
xmlValidation
- true to enable xml validation
-
getXmlBlockExternal
boolean getXmlBlockExternal()Will the parsing of web.xml, web-fragment.xml, *.tld, *.jspx, *.tagx and tagplugin.xml files for this Context block the use of external entities?- Returns:
- true if access to external entities is blocked
-
setXmlBlockExternal
void setXmlBlockExternal(boolean xmlBlockExternal) Controls whether the parsing of web.xml, web-fragment.xml, *.tld, *.jspx, *.tagx and tagplugin.xml files for this Context will block the use of external entities.- Parameters:
xmlBlockExternal
- true to block external entities
-
getTldValidation
boolean getTldValidation()Will the parsing of *.tld files for this Context be performed by a validating parser?- Returns:
- true if validation is enabled.
-
setTldValidation
void setTldValidation(boolean tldValidation) Controls whether the parsing of *.tld files for this Context will be performed by a validating parser.- Parameters:
tldValidation
- true to enable xml validation
-
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
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()- Returns:
- the
Authenticator
that is used by this context. This is always non-null
for a started Context
-
setLogEffectiveWebXml
void setLogEffectiveWebXml(boolean logEffectiveWebXml) Set whether or not the effective web.xml for this context should be logged on context start.- Parameters:
logEffectiveWebXml
- set totrue
to log the complete web.xml that will be used for the webapp
-
getLogEffectiveWebXml
boolean getLogEffectiveWebXml()Should the effective web.xml for this context be logged on context start?- Returns:
- true if the reconstructed web.xml that will be used for the webapp should be logged
-
getInstanceManager
InstanceManager getInstanceManager()- Returns:
- the instance manager associated with this context.
-
setInstanceManager
Set the instance manager associated with this context.- Parameters:
instanceManager
- the new instance manager instance
-
setContainerSciFilter
Sets the regular expression that specifies which container provided SCIs should be filtered out and not used for this context. Matching usesMatcher.find()
so the regular expression only has to match a sub-string of the fully qualified class name of the container provided SCI for it to be filtered out.- Parameters:
containerSciFilter
- The regular expression against which the fully qualified class name of each container provided SCI should be checked
-
getContainerSciFilter
String getContainerSciFilter()Obtains the regular expression that specifies which container provided SCIs should be filtered out and not used for this context. Matching usesMatcher.find()
so the regular expression only has to match a sub-string of the fully qualified class name of the container provided SCI for it to be filtered out.- Returns:
- The regular expression against which the fully qualified class name of each container provided SCI will be checked
-
getParallelAnnotationScanning
boolean getParallelAnnotationScanning()- Returns:
- the value of the parallel annotation scanning flag. If true, it will dispatch scanning to the utility executor.
-
setParallelAnnotationScanning
void setParallelAnnotationScanning(boolean parallelAnnotationScanning) Set the parallel annotation scanning value.- Parameters:
parallelAnnotationScanning
- new parallel annotation scanning flag
-
addApplicationListener
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
Add a new application parameter for this application.- Parameters:
parameter
- The new application parameter
-
addConstraint
Add a security constraint to the set for this web application.- Parameters:
constraint
- The security constraint that should be added
-
addErrorPage
Add an error page for the specified error or Java exception.- Parameters:
errorPage
- The error page definition to be added
-
addFilterDef
Add a filter definition to this Context.- Parameters:
filterDef
- The filter definition to be added
-
addFilterMap
Add a filter mapping to this Context.- Parameters:
filterMap
- The filter mapping to be added
-
addFilterMapBefore
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
-
addLocaleEncodingMappingParameter
-
addMimeMapping
-
addParameter
-
addRoleMapping
-
addSecurityRole
Add a new security role for this web application.- Parameters:
role
- New security role
-
addServletMappingDecoded
-
addServletMappingDecoded
Add a new servlet mapping, replacing any existing mapping for the specified pattern.- Parameters:
pattern
- URL pattern to be mappedname
- Name of the corresponding servlet to executejspWildcard
- true if name identifies the JspServlet and pattern contains a wildcard; false otherwise
-
addWatchedResource
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
Add a new welcome file to the set recognized by this Context.- Parameters:
name
- New welcome file name
-
addWrapperLifecycle
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
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
-
createInstanceManager
InstanceManager createInstanceManager()Factory method to create and return a new InstanceManager instance. This can be used for framework integration or easier configuration with custom Context implementations.- Returns:
- the instance manager
-
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.- Returns:
- a newly created wrapper instance that is used to wrap a Servlet
-
findApplicationListeners
String[] findApplicationListeners()- Returns:
- the set of application listener class names configured for this application.
-
findApplicationParameters
ApplicationParameter[] findApplicationParameters()- Returns:
- the set of application parameters for this application.
-
findConstraints
SecurityConstraint[] findConstraints()- Returns:
- the set of security constraints for this web application. If there are none, a zero-length array is returned.
-
findErrorPage
- Parameters:
errorCode
- Error code to look up- Returns:
- the error page entry for the specified HTTP error code, if any; otherwise return
null
.
-
findErrorPage
Find and return the ErrorPage instance for the specified exception's class, or an ErrorPage instance for the closest superclass for which there is such a definition. If no associated ErrorPage instance is found, returnnull
.- Parameters:
throwable
- The exception type for which to find an ErrorPage- Returns:
- the error page entry for the specified Java exception type, if any; otherwise return
null
.
-
findErrorPages
ErrorPage[] findErrorPages()- Returns:
- the set of defined error pages for all specified error codes and exception types.
-
findFilterDef
-
findFilterDefs
FilterDef[] findFilterDefs()- Returns:
- the set of defined filters for this Context.
-
findFilterMaps
FilterMap[] findFilterMaps()- Returns:
- the set of filter mappings for this Context.
-
findMimeMapping
-
findMimeMappings
String[] findMimeMappings()- Returns:
- the extensions for which MIME mappings are defined. If there are none, a zero-length array is returned.
-
findParameter
-
findParameters
String[] findParameters()- Returns:
- the names of all defined context initialization parameters for this Context. If no parameters are defined, a zero-length array is returned.
-
findRoleMapping
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- Returns:
- The role name that was mapped to the specified role
-
findSecurityRole
- Parameters:
role
- Security role to verify- Returns:
true
if the specified security role is defined for this application; otherwise returnfalse
.
-
findSecurityRoles
String[] findSecurityRoles()- Returns:
- the security roles defined for this application. If none have been defined, a zero-length array is returned.
-
findServletMapping
-
findServletMappings
String[] findServletMappings()- Returns:
- the patterns of all defined servlet mappings for this Context. If no mappings are defined, a zero-length array is returned.
-
getThreadBindingListener
ThreadBindingListener getThreadBindingListener()- Returns:
- the associated ThreadBindingListener.
-
setThreadBindingListener
Get the associated ThreadBindingListener.- Parameters:
threadBindingListener
- Set the listener that will receive notifications when entering and exiting the application scope
-
findWatchedResources
String[] findWatchedResources()- Returns:
- the set of watched resources for this Context. If none are defined, a zero length array will be returned.
-
findWelcomeFile
- Parameters:
name
- Welcome file to verify- Returns:
true
if the specified welcome file is defined for this Context; otherwise returnfalse
.
-
findWelcomeFiles
String[] findWelcomeFiles()- Returns:
- the set of welcome files defined for this Context. If none are defined, a zero-length array is returned.
-
findWrapperLifecycles
String[] findWrapperLifecycles()- Returns:
- the set of LifecycleListener classes that will be added to newly created Wrappers automatically.
-
findWrapperListeners
String[] findWrapperListeners()- Returns:
- the set of ContainerListener classes that will be added to newly created Wrappers automatically.
-
fireRequestInitEvent
Notify allServletRequestListener
s that a request has started.- Parameters:
request
- The request object that will be passed to the listener- Returns:
true
if the listeners fire successfully, elsefalse
-
fireRequestDestroyEvent
Notify allServletRequestListener
s that a request has ended.- Parameters:
request
- The request object that will be passed to the listener- Returns:
true
if the listeners fire successfully, elsefalse
-
reload
void reload()Reload this web application, if reloading is supported.- Throws:
IllegalStateException
- if thereloadable
property is set tofalse
.
-
removeApplicationListener
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
Remove the application parameter with the specified name from the set for this application.- Parameters:
name
- Name of the application parameter to remove
-
removeConstraint
Remove the specified security constraint from this web application.- Parameters:
constraint
- Constraint to be removed
-
removeErrorPage
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
Remove the specified filter definition from this Context, if it exists; otherwise, no action is taken.- Parameters:
filterDef
- Filter definition to be removed
-
removeFilterMap
Remove a filter mapping from this Context.- Parameters:
filterMap
- The filter mapping to be removed
-
removeMimeMapping
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
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
Remove any security role reference for the specified name- Parameters:
role
- Security role (as used in the application) to remove
-
removeSecurityRole
Remove any security role with the specified name.- Parameters:
role
- Security role to remove
-
removeServletMapping
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
Remove the specified watched resource name from the list associated with this Context.- Parameters:
name
- Name of the watched resource to be removed
-
removeWelcomeFile
Remove the specified welcome file name from the list recognized by this Context.- Parameters:
name
- Name of the welcome file to be removed
-
removeWrapperLifecycle
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
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
-
getEffectiveMajorVersion
int getEffectiveMajorVersion()- Returns:
- 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.- Parameters:
major
- Set the version number
-
getEffectiveMinorVersion
int getEffectiveMinorVersion()- Returns:
- 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.- Parameters:
minor
- Set the version number
-
getJspConfigDescriptor
JspConfigDescriptor getJspConfigDescriptor()- Returns:
- the JSP configuration for this context. Will be null if there is no JSP configuration.
-
setJspConfigDescriptor
Set the JspConfigDescriptor for this context. A null value indicates there is not JSP configuration.- Parameters:
descriptor
- the new JSP configuration
-
addServletContainerInitializer
Add a ServletContainerInitializer instance to this web application.- Parameters:
sci
- The instance to addclasses
- The classes in which the initializer expressed an interest
-
getPaused
boolean getPaused()Is this Context paused whilst it is reloaded?- Returns:
true
if the context has been paused
-
isServlet22
boolean isServlet22()Is this context using version 2.2 of the Servlet spec?- Returns:
true
for a legacy Servlet 2.2 webapp
-
addServletSecurity
Set<String> addServletSecurity(ServletRegistration.Dynamic registration, ServletSecurityElement servletSecurityElement) Notification that Servlet security has been dynamically set in aServletRegistration.Dynamic
- Parameters:
registration
- Servlet security was modified forservletSecurityElement
- new security constraints for this Servlet- Returns:
- urls currently mapped to this registration that are already present in web.xml
-
setResourceOnlyServlets
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.- Parameters:
resourceOnlyServlets
- The Servlet names comma separated list
-
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
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, otherwisefalse
-
getBaseName
String getBaseName()- Returns:
- the base name to use for WARs, directories or context.xml files for this context.
-
setWebappVersion
Set the version of this web application - used to differentiate different versions of the same web application when using parallel deployment.- Parameters:
webappVersion
- The webapp version associated with the context, which should be unique
-
getWebappVersion
String getWebappVersion()- Returns:
- 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.- Parameters:
enable
-true
to fire request listeners when forwarding
-
getFireRequestListenersOnForwards
boolean getFireRequestListenersOnForwards()- Returns:
- 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.- Parameters:
enable
-true
to perform authentication even outside security constraints
-
getPreemptiveAuthentication
boolean getPreemptiveAuthentication()- Returns:
- 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.- Parameters:
enable
-true
to send a response body for redirects
-
getSendRedirectBody
boolean getSendRedirectBody()- Returns:
- if the context is configured to include a response body as part of a redirect response.
-
getLoader
Loader getLoader()- Returns:
- the Loader with which this Context is associated.
-
setLoader
Set the Loader with which this Context is associated.- Parameters:
loader
- The newly associated loader
-
getResources
WebResourceRoot getResources()- Returns:
- the Resources with which this Context is associated.
-
setResources
Set the Resources object with which this Context is associated.- Parameters:
resources
- The newly associated Resources
-
getManager
Manager getManager()- Returns:
- the Manager with which this Context is associated. If there is no associated Manager, return
null
.
-
setManager
Set the Manager with which this Context is associated.- Parameters:
manager
- The newly associated Manager
-
setAddWebinfClassesResources
void setAddWebinfClassesResources(boolean addWebinfClassesResources) Sets the flag that indicates if /WEB-INF/classes should be treated like an exploded JAR and JAR resources made available as if they were in a JAR.- Parameters:
addWebinfClassesResources
- The new value for the flag
-
getAddWebinfClassesResources
boolean getAddWebinfClassesResources()- Returns:
- the flag that indicates if /WEB-INF/classes should be treated like an exploded JAR and JAR resources made available as if they were in a JAR.
-
addPostConstructMethod
Add a post construct method definition for the given class, if there is an existing definition for the specified class - IllegalArgumentException will be thrown.- Parameters:
clazz
- Fully qualified class namemethod
- Post construct method name- Throws:
IllegalArgumentException
- if the fully qualified class name or method name areNULL
; if there is already post construct method definition for the given class
-
addPreDestroyMethod
Add a pre destroy method definition for the given class, if there is an existing definition for the specified class - IllegalArgumentException will be thrown.- Parameters:
clazz
- Fully qualified class namemethod
- Post construct method name- Throws:
IllegalArgumentException
- if the fully qualified class name or method name areNULL
; if there is already pre destroy method definition for the given class
-
removePostConstructMethod
Removes the post construct method definition for the given class, if it exists; otherwise, no action is taken.- Parameters:
clazz
- Fully qualified class name
-
removePreDestroyMethod
Removes the pre destroy method definition for the given class, if it exists; otherwise, no action is taken.- Parameters:
clazz
- Fully qualified class name
-
findPostConstructMethod
Returns the method name that is specified as post construct method for the given class, if it exists; otherwiseNULL
will be returned.- Parameters:
clazz
- Fully qualified class name- Returns:
- the method name that is specified as post construct method for the given class, if it exists; otherwise
NULL
will be returned.
-
findPreDestroyMethod
Returns the method name that is specified as pre destroy method for the given class, if it exists; otherwiseNULL
will be returned.- Parameters:
clazz
- Fully qualified class name- Returns:
- the method name that is specified as pre destroy method for the given class, if it exists; otherwise
NULL
will be returned.
-
findPostConstructMethods
Returns a map with keys - fully qualified class names of the classes that have post construct methods and the values are the corresponding method names. If there are no such classes an empty map will be returned.- Returns:
- a map with keys - fully qualified class names of the classes that have post construct methods and the values are the corresponding method names.
-
findPreDestroyMethods
Returns a map with keys - fully qualified class names of the classes that have pre destroy methods and the values are the corresponding method names. If there are no such classes an empty map will be returned.- Returns:
- a map with keys - fully qualified class names of the classes that have pre destroy methods and the values are the corresponding method names.
-
getNamingToken
Object getNamingToken()- Returns:
- the token necessary for operations on the associated JNDI naming context.
-
setCookieProcessor
Sets theCookieProcessor
that will be used to process cookies for this Context.- Parameters:
cookieProcessor
- The new cookie processor- Throws:
IllegalArgumentException
- If anull
CookieProcessor is specified
-
getCookieProcessor
CookieProcessor getCookieProcessor()- Returns:
- the
CookieProcessor
that will be used to process cookies for this Context.
-
setValidateClientProvidedNewSessionId
void setValidateClientProvidedNewSessionId(boolean validateClientProvidedNewSessionId) When a client provides the ID for a new session, should that ID be validated? The only use case for using a client provided session ID is to have a common session ID across multiple web applications. Therefore, any client provided session ID should already exist in another web application. If this check is enabled, the client provided session ID will only be used if the session ID exists in at least one other web application for the current host. Note that the following additional tests are always applied, irrespective of this setting:- The session ID is provided by a cookie
- The session cookie has a path of
/
- Parameters:
validateClientProvidedNewSessionId
-true
if validation should be applied
-
getValidateClientProvidedNewSessionId
boolean getValidateClientProvidedNewSessionId()Will client provided session IDs be validated (seesetValidateClientProvidedNewSessionId(boolean)
) before use?- Returns:
true
if validation will be applied. Otherwise,false
-
setMapperContextRootRedirectEnabled
void setMapperContextRootRedirectEnabled(boolean mapperContextRootRedirectEnabled) If enabled, requests for a web application context root will be redirected (adding a trailing slash) by the Mapper. This is more efficient but has the side effect of confirming that the context path is valid.- Parameters:
mapperContextRootRedirectEnabled
- Should the redirects be enabled?
-
getMapperContextRootRedirectEnabled
boolean getMapperContextRootRedirectEnabled()Determines if requests for a web application context root will be redirected (adding a trailing slash) by the Mapper. This is more efficient but has the side effect of confirming that the context path is valid.- Returns:
true
if the Mapper level redirect is enabled for this Context.
-
setMapperDirectoryRedirectEnabled
void setMapperDirectoryRedirectEnabled(boolean mapperDirectoryRedirectEnabled) If enabled, requests for a directory will be redirected (adding a trailing slash) by the Mapper. This is more efficient but has the side effect of confirming that the directory is valid.- Parameters:
mapperDirectoryRedirectEnabled
- Should the redirects be enabled?
-
getMapperDirectoryRedirectEnabled
boolean getMapperDirectoryRedirectEnabled()Determines if requests for a directory will be redirected (adding a trailing slash) by the Mapper. This is more efficient but has the side effect of confirming that the directory is valid.- Returns:
true
if the Mapper level redirect is enabled for this Context.
-
setUseRelativeRedirects
void setUseRelativeRedirects(boolean useRelativeRedirects) Controls whether HTTP 1.1 and later location headers generated by a call toHttpServletResponse.sendRedirect(String)
will use relative or absolute redirects.Relative redirects are more efficient but may not work with reverse proxies that change the context path. It should be noted that it is not recommended to use a reverse proxy to change the context path because of the multiple issues it creates.
Absolute redirects should work with reverse proxies that change the context path but may cause issues with the
RemoteIpFilter
if the filter is changing the scheme and/or port.- Parameters:
useRelativeRedirects
-true
to use relative redirects andfalse
to use absolute redirects
-
getUseRelativeRedirects
boolean getUseRelativeRedirects()Will HTTP 1.1 and later location headers generated by a call toHttpServletResponse.sendRedirect(String)
use relative or absolute redirects.- Returns:
true
if relative redirects will be usedfalse
if absolute redirects are used.- See Also:
-
setDispatchersUseEncodedPaths
void setDispatchersUseEncodedPaths(boolean dispatchersUseEncodedPaths) Are paths used in calls to obtain a request dispatcher expected to be encoded? This affects both how Tomcat handles calls to obtain a request dispatcher as well as how Tomcat generates paths used to obtain request dispatchers internally.- Parameters:
dispatchersUseEncodedPaths
-true
to use encoded paths, otherwisefalse
-
getDispatchersUseEncodedPaths
boolean getDispatchersUseEncodedPaths()Are paths used in calls to obtain a request dispatcher expected to be encoded? This applies to both how Tomcat handles calls to obtain a request dispatcher as well as how Tomcat generates paths used to obtain request dispatchers internally.- Returns:
true
if encoded paths will be used, otherwisefalse
-
setRequestCharacterEncoding
Set the default request body encoding for this web application.- Parameters:
encoding
- The default encoding
-
getRequestCharacterEncoding
String getRequestCharacterEncoding()Get the default request body encoding for this web application.- Returns:
- The default request body encoding
-
setResponseCharacterEncoding
Set the default response body encoding for this web application.- Parameters:
encoding
- The default encoding
-
getResponseCharacterEncoding
String getResponseCharacterEncoding()Get the default response body encoding for this web application.- Returns:
- The default response body encoding
-
setAllowMultipleLeadingForwardSlashInPath
void setAllowMultipleLeadingForwardSlashInPath(boolean allowMultipleLeadingForwardSlashInPath) Configure if, when returning a context path fromHttpServletRequest.getContextPath()
, the return value is allowed to contain multiple leading '/' characters.- Parameters:
allowMultipleLeadingForwardSlashInPath
- The new value for the flag
-
getAllowMultipleLeadingForwardSlashInPath
boolean getAllowMultipleLeadingForwardSlashInPath()When returning a context path fromHttpServletRequest.getContextPath()
, is it allowed to contain multiple leading '/' characters?- Returns:
true
if multiple leading '/' characters are allowed, otherwisefalse
-
incrementInProgressAsyncCount
void incrementInProgressAsyncCount() -
decrementInProgressAsyncCount
void decrementInProgressAsyncCount() -
setCreateUploadTargets
void setCreateUploadTargets(boolean createUploadTargets) Configure whether Tomcat will attempt to create an upload target used by this web application if it does not exist when the web application attempts to use it.- Parameters:
createUploadTargets
-true
if Tomcat should attempt to create the upload target, otherwisefalse
-
getCreateUploadTargets
boolean getCreateUploadTargets()Will Tomcat attempt to create an upload target used by this web application if it does not exist when the web application attempts to use it?- Returns:
true
if Tomcat will attempt to create an upload target otherwisefalse
-
getAlwaysAccessSession
boolean getAlwaysAccessSession()If this istrue
, every request that is associated with a session will cause the session's last accessed time to be updated regardless of whether or not the request explicitly accesses the session. Iforg.apache.catalina.STRICT_SERVLET_COMPLIANCE
is set totrue
, the default of this setting will betrue
, else the default value will befalse
.- Returns:
- the flag value
-
setAlwaysAccessSession
void setAlwaysAccessSession(boolean alwaysAccessSession) Set the session access behavior.- Parameters:
alwaysAccessSession
- the new flag value
-
getContextGetResourceRequiresSlash
boolean getContextGetResourceRequiresSlash()If this istrue
then the path passed toServletContext.getResource()
orServletContext.getResourceAsStream()
must start with "/". Iffalse
, code likegetResource("myfolder/myresource.txt")
will work as Tomcat will prepend "/" to the provided path. Iforg.apache.catalina.STRICT_SERVLET_COMPLIANCE
is set totrue
, the default of this setting will betrue
, else the default value will befalse
.- Returns:
- the flag value
-
setContextGetResourceRequiresSlash
void setContextGetResourceRequiresSlash(boolean contextGetResourceRequiresSlash) Allow usingServletContext.getResource()
orServletContext.getResourceAsStream()
without a leading "/".- Parameters:
contextGetResourceRequiresSlash
- the new flag value
-
getDispatcherWrapsSameObject
boolean getDispatcherWrapsSameObject()If this istrue
then any wrapped request or response object passed to an application dispatcher will be checked to ensure that it has wrapped the original request or response. Iforg.apache.catalina.STRICT_SERVLET_COMPLIANCE
is set totrue
, the default of this setting will betrue
, else the default value will befalse
.- Returns:
- the flag value
-
setDispatcherWrapsSameObject
void setDispatcherWrapsSameObject(boolean dispatcherWrapsSameObject) Allow disabling the object wrap check in the request dispatcher.- Parameters:
dispatcherWrapsSameObject
- the new flag value
-
getSuspendWrappedResponseAfterForward
boolean getSuspendWrappedResponseAfterForward()If this istrue
, then following a forward the response will be unwrapped to suspend the Catalina response instead of simply closing the top level response. The default value istrue
.- Returns:
- the flag value
-
setSuspendWrappedResponseAfterForward
void setSuspendWrappedResponseAfterForward(boolean suspendWrappedResponseAfterForward) Allows unwrapping the response object to suspend the response following a forward.- Parameters:
suspendWrappedResponseAfterForward
- the new flag value
-
findConfigFileResource
Find configuration file with the specified path, first looking into the webapp resources, then delegating toConfigFileLoader.getSource().getResource
. TheWEBAPP_PROTOCOL
constant prefix is used to denote webapp resources.- Parameters:
name
- The resource name- Returns:
- the resource
- Throws:
IOException
- if an error occurs or if the resource does not exist
-