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 SummaryNested classes/interfaces inherited from interface org.apache.catalina.LifecycleLifecycle.SingleUse
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final StringContainer event for adding a welcome file.static final StringContainer event for changing the ID of a session.static final StringContainer event for clearing welcome files.static final StringContainer event for removing a wrapper.static final StringPrefix for resource lookup.Fields inherited from interface org.apache.catalina.ContainerADD_CHILD_EVENT, ADD_VALVE_EVENT, REMOVE_CHILD_EVENT, REMOVE_VALVE_EVENTFields inherited from interface org.apache.catalina.LifecycleAFTER_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 SummaryModifier and TypeMethodDescriptionvoidaddApplicationListener(String listener) Add a new Listener class name to the set of Listeners configured for this application.voidaddApplicationParameter(ApplicationParameter parameter) Add a new application parameter for this application.voidaddConstraint(SecurityConstraint constraint) Add a security constraint to the set for this web application.voidaddErrorPage(ErrorPage errorPage) Add an error page for the specified error or Java exception.voidaddFilterDef(FilterDef filterDef) Add a filter definition to this Context.voidaddFilterMap(FilterMap filterMap) Add a filter mapping to this Context.voidaddFilterMapBefore(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.voidaddLocaleEncodingMappingParameter(String locale, String encoding) Add a Locale Encoding Mapping (see Sec 5.4 of Servlet spec 2.4)voidaddMimeMapping(String extension, String mimeType) Add a new MIME mapping, replacing any existing mapping for the specified extension.voidaddParameter(String name, String value) Add a new context initialization parameter, replacing any existing value for the specified name.voidaddPostConstructMethod(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.voidaddPreDestroyMethod(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.voidaddRoleMapping(String role, String link) Add a security role reference for this web application.voidaddSecurityRole(String role) Add a new security role for this web application.voidaddServletContainerInitializer(ServletContainerInitializer sci, Set<Class<?>> classes) Add a ServletContainerInitializer instance to this web application.default voidaddServletMappingDecoded(String pattern, String name) Add a new servlet mapping, replacing any existing mapping for the specified pattern.voidaddServletMappingDecoded(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.DynamicvoidaddWatchedResource(String name) Add a resource which will be watched for reloading by the host auto deployer.voidaddWelcomeFile(String name) Add a new welcome file to the set recognized by this Context.voidaddWrapperLifecycle(String listener) Add the classname of a LifecycleListener to be added to each Wrapper appended to this Context.voidaddWrapperListener(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.voidString[]default ConfigurationSource.ResourcefindConfigFileResource(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; otherwiseNULLwill 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; otherwiseNULLwill 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.booleanfindSecurityRole(String role) String[]findServletMapping(String pattern) String[]String[]booleanfindWelcomeFile(String name) String[]String[]String[]booleanfireRequestDestroyEvent(ServletRequest request) Notify allServletRequestListeners that a request has ended.booleanfireRequestInitEvent(ServletRequest request) Notify allServletRequestListeners that a request has started.booleanbooleanReturnstrueif requests mapped to servlets without "multipart config" to parse multipart/form-data requests anyway.booleanWhen returning a context path fromHttpServletRequest.getContextPath(), is it allowed to contain multiple leading '/' characters?Return the alternate Deployment Descriptor name.booleanIf 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.booleanReturn 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.booleanIf this istruethen the path passed toServletContext.getResource()orServletContext.getResourceAsStream()must start with "/".booleanReturn the "use cookies for session ids" flag.booleanWill 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?booleanReturn the "allow crossing servlet contexts" flag.booleanReturn the deny-uncovered-http-methods flag for this web application.booleanAre paths used in calls to obtain a request dispatcher expected to be encoded?booleanIf this istruethen 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.booleanGet the distributable flag for this web application.Obtain the document root for this Context.intintReturn the URL encoded context pathbooleanbooleanDetermine if annotations parsing is currently disabledGet the Jar Scanner to be used to scan for JAR resources for this context.booleanShould the effective web.xml for this context be logged on context start?booleanDetermines if requests for a web application context root will be redirected (adding a trailing slash) by the Mapper.booleanDetermines if requests for a directory will be redirected (adding a trailing slash) by the Mapper.booleanbooleangetPath()booleanIs this Context paused whilst it is reloaded?booleanbooleangetRealPath(String path) booleanGet 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.booleanGets the domain to use for session cookies.Gets the name to use for session cookies.Gets the path to use for session cookies.booleanIs 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.intbooleanReturnstrueif remaining request data will be read (swallowed) even the request violates a data size constraint.booleanbooleanWill the parsing of *.tld files for this Context be performed by a validating parser?booleanDeprecated.This method will be removed in Tomcat 11 onwards.booleanGets the value of the use HttpOnly cookies for session cookies flag.booleanShould thePartitionedattribute be added to session cookies created for this web application.booleanWill HTTP 1.1 and later location headers generated by a call toHttpServletResponse.sendRedirect(String)use relative or absolute redirects.booleanWill client provided session IDs be validated (seesetValidateClientProvidedNewSessionId(boolean)) before use?booleanWill the parsing of web.xml, web-fragment.xml, *.tld, *.jspx, *.tagx and tagplugin.xml files for this Context block the use of external entities?booleanWill the parsing of web.xml and web-fragment.xml files for this Context be performed by a namespace aware parser?booleanWill the parsing of web.xml and web-fragment.xml files for this Context be performed by a validating parser?voiddefault booleanDeprecated.This method will be removed in Tomcat 11 onwardsbooleanisResourceOnlyServlet(String servletName) Checks the named Servlet to see if it expects a resource to be present.booleanIs this context using version 2.2 of the Servlet spec?voidreload()Reload this web application, if reloading is supported.voidremoveApplicationListener(String listener) Remove the specified application listener class from the set of listeners for this application.voidRemove the application parameter with the specified name from the set for this application.voidremoveConstraint(SecurityConstraint constraint) Remove the specified security constraint from this web application.voidremoveErrorPage(ErrorPage errorPage) Remove the error page for the specified error code or Java language exception, if it exists; otherwise, no action is taken.voidremoveFilterDef(FilterDef filterDef) Remove the specified filter definition from this Context, if it exists; otherwise, no action is taken.voidremoveFilterMap(FilterMap filterMap) Remove a filter mapping from this Context.voidremoveMimeMapping(String extension) Remove the MIME mapping for the specified extension, if it exists; otherwise, no action is taken.voidremoveParameter(String name) Remove the context initialization parameter with the specified name, if it exists; otherwise, no action is taken.voidremovePostConstructMethod(String clazz) Removes the post construct method definition for the given class, if it exists; otherwise, no action is taken.voidremovePreDestroyMethod(String clazz) Removes the pre destroy method definition for the given class, if it exists; otherwise, no action is taken.voidremoveRoleMapping(String role) Remove any security role reference for the specified namevoidremoveSecurityRole(String role) Remove any security role with the specified name.voidremoveServletMapping(String pattern) Remove any servlet mapping for the specified pattern, if it exists; otherwise, no action is taken.voidremoveWatchedResource(String name) Remove the specified watched resource name from the list associated with this Context.voidremoveWelcomeFile(String name) Remove the specified welcome file name from the list recognized by this Context.voidremoveWrapperLifecycle(String listener) Remove a class name from the set of LifecycleListener classes that will be added to newly created Wrappers.voidremoveWrapperListener(String listener) Remove a class name from the set of ContainerListener classes that will be added to newly created Wrappers.voidsetAddWebinfClassesResources(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.voidsetAllowCasualMultipartParsing(boolean allowCasualMultipartParsing) Set totrueto 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.voidsetAllowMultipleLeadingForwardSlashInPath(boolean allowMultipleLeadingForwardSlashInPath) Configure if, when returning a context path fromHttpServletRequest.getContextPath(), the return value is allowed to contain multiple leading '/' characters.voidsetAltDDName(String altDDName) Set an alternate Deployment Descriptor name.voidsetAlwaysAccessSession(boolean alwaysAccessSession) Set the session access behavior.voidsetApplicationEventListeners(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.voidsetApplicationLifecycleListeners(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.voidsetConfigFile(URL configFile) Set the URL of the XML descriptor for this context.voidsetConfigured(boolean configured) Set the "correctly configured" flag for this Context.voidsetContainerSciFilter(String containerSciFilter) Sets the regular expression that specifies which container provided SCIs should be filtered out and not used for this context.voidsetContextGetResourceRequiresSlash(boolean contextGetResourceRequiresSlash) Allow usingServletContext.getResource()orServletContext.getResourceAsStream()without a leading "/".voidsetCookieProcessor(CookieProcessor cookieProcessor) Sets theCookieProcessorthat will be used to process cookies for this Context.voidsetCookies(boolean cookies) Set the "use cookies for session ids" flag.voidsetCreateUploadTargets(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.voidsetCrossContext(boolean crossContext) Set the "allow crossing servlet contexts" flag.voidsetDenyUncoveredHttpMethods(boolean denyUncoveredHttpMethods) Set the deny-uncovered-http-methods flag for this web application.voidsetDispatchersUseEncodedPaths(boolean dispatchersUseEncodedPaths) Are paths used in calls to obtain a request dispatcher expected to be encoded?voidsetDispatcherWrapsSameObject(boolean dispatcherWrapsSameObject) Allow disabling the object wrap check in the request dispatcher.voidsetDisplayName(String displayName) Set the display name of this web application.voidsetDistributable(boolean distributable) Set the distributable flag for this web application.voidsetDocBase(String docBase) Set the document root for this Context.voidsetEffectiveMajorVersion(int major) Set the effective major version of the Servlet spec used by this context.voidsetEffectiveMinorVersion(int minor) Set the effective minor version of the Servlet spec used by this context.voidsetFireRequestListenersOnForwards(boolean enable) Configure whether or not requests listeners will be fired on forwards for this Context.voidsetIgnoreAnnotations(boolean ignoreAnnotations) Set the boolean on the annotations parsing for this web application.voidsetInstanceManager(InstanceManager instanceManager) Set the instance manager associated with this context.voidsetJarScanner(JarScanner jarScanner) Set the Jar Scanner to be used to scan for JAR resources for this context.voidsetJspConfigDescriptor(JspConfigDescriptor descriptor) Set the JspConfigDescriptor for this context.voidSet the Loader with which this Context is associated.voidsetLogEffectiveWebXml(boolean logEffectiveWebXml) Set whether or not the effective web.xml for this context should be logged on context start.voidsetLoginConfig(LoginConfig config) Set the login configuration descriptor for this web application.voidsetManager(Manager manager) Set the Manager with which this Context is associated.voidsetMapperContextRootRedirectEnabled(boolean mapperContextRootRedirectEnabled) If enabled, requests for a web application context root will be redirected (adding a trailing slash) by the Mapper.voidsetMapperDirectoryRedirectEnabled(boolean mapperDirectoryRedirectEnabled) If enabled, requests for a directory will be redirected (adding a trailing slash) by the Mapper.voidsetNamingResources(NamingResourcesImpl namingResources) Set the naming resources for this web application.voidsetOverride(boolean override) Set the override flag for this web application.voidsetParallelAnnotationScanning(boolean parallelAnnotationScanning) Set the parallel annotation scanning value.voidSet the context path for this web application.voidsetPreemptiveAuthentication(boolean enable) Configures if a user presents authentication credentials, whether the context will process them when the request is for a non-protected resource.voidsetPrivileged(boolean privileged) Set the privileged flag for this web application.voidsetPublicId(String publicId) Set the public identifier of the deployment descriptor DTD that is currently being parsed.voidsetReloadable(boolean reloadable) Set the reloadable flag for this web application.voidsetRequestCharacterEncoding(String encoding) Set the default request body encoding for this web application.voidsetResourceOnlyServlets(String resourceOnlyServlets) Sets the (comma separated) list of Servlets that expect a resource to be present.voidsetResources(WebResourceRoot resources) Set the Resources object with which this Context is associated.voidsetResponseCharacterEncoding(String encoding) Set the default response body encoding for this web application.voidsetSendRedirectBody(boolean enable) Configures if a response body is included when a redirect response is sent to the client.voidsetSessionCookieDomain(String sessionCookieDomain) Sets the domain to use for session cookies.voidsetSessionCookieName(String sessionCookieName) Sets the name to use for session cookies.voidsetSessionCookiePath(String sessionCookiePath) Sets the path to use for session cookies.voidsetSessionCookiePathUsesTrailingSlash(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.voidsetSessionTimeout(int timeout) Set the default session timeout (in minutes) for this web application.voidsetSwallowAbortedUploads(boolean swallowAbortedUploads) Set tofalseto disable request data swallowing after an upload was aborted due to size constraints.voidsetSwallowOutput(boolean swallowOutput) Set the value of the swallowOutput flag.voidsetThreadBindingListener(ThreadBindingListener threadBindingListener) Get the associated ThreadBindingListener.voidsetTldValidation(boolean tldValidation) Controls whether the parsing of *.tld files for this Context will be performed by a validating parser.voidsetUseBloomFilterForArchives(boolean useBloomFilterForArchives) Deprecated.This method will be removed in Tomcat 11 onwards UseWebResourceRoot.setArchiveIndexStrategy(String)voidsetUseHttpOnly(boolean useHttpOnly) Sets the use HttpOnly cookies for session cookies flag.voidsetUsePartitioned(boolean usePartitioned) Configure whether thePartitionedattribute should be added to session cookies created for this web application.voidsetUseRelativeRedirects(boolean useRelativeRedirects) Controls whether HTTP 1.1 and later location headers generated by a call toHttpServletResponse.sendRedirect(String)will use relative or absolute redirects.voidsetValidateClientProvidedNewSessionId(boolean validateClientProvidedNewSessionId) When a client provides the ID for a new session, should that ID be validated?voidsetWebappVersion(String webappVersion) Set the version of this web application - used to differentiate different versions of the same web application when using parallel deployment.voidsetWrapperClass(String wrapperClass) Set the Java class name of the Wrapper implementation used for servlets registered in this Context.voidsetXmlBlockExternal(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.voidsetXmlNamespaceAware(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.voidsetXmlValidation(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.ContaineraddChild, 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, setStartStopThreadsMethods inherited from interface org.apache.tomcat.ContextBindbind, unbindMethods inherited from interface org.apache.catalina.LifecycleaddLifecycleListener, destroy, findLifecycleListeners, getState, getStateName, init, removeLifecycleListener, start, stop
- 
Field Details- 
ADD_WELCOME_FILE_EVENTContainer event for adding a welcome file.- See Also:
 
- 
REMOVE_WELCOME_FILE_EVENTContainer event for removing a wrapper.- See Also:
 
- 
CLEAR_WELCOME_FILES_EVENTContainer event for clearing welcome files.- See Also:
 
- 
CHANGE_SESSION_ID_EVENTContainer event for changing the ID of a session.- See Also:
 
- 
WEBAPP_PROTOCOLPrefix for resource lookup.- See Also:
 
 
- 
- 
Method Details- 
getAllowCasualMultipartParsingboolean getAllowCasualMultipartParsing()Returnstrueif requests mapped to servlets without "multipart config" to parse multipart/form-data requests anyway.- Returns:
- trueif requests mapped to servlets without "multipart config" to parse multipart/form-data requests,- falseotherwise.
 
- 
setAllowCasualMultipartParsingvoid setAllowCasualMultipartParsing(boolean allowCasualMultipartParsing) Set totrueto 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-- trueto allow such casual parsing,- falseotherwise.
 
- 
getApplicationEventListenersObject[] 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
 
- 
setApplicationEventListenersStore 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.
 
- 
getApplicationLifecycleListenersObject[] 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
 
- 
setApplicationLifecycleListenersStore 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.
 
- 
getCharsetObtain 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
 
- 
getConfigFileURL getConfigFile()Return the URL of the XML descriptor for this context.- Returns:
- The URL of the XML descriptor for this context
 
- 
setConfigFileSet the URL of the XML descriptor for this context.- Parameters:
- configFile- The URL of the XML descriptor for this context.
 
- 
getConfiguredboolean getConfigured()Return the "correctly configured" flag for this Context.- Returns:
- trueif the Context has been correctly configured, otherwise- false
 
- 
setConfiguredvoid 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
 
- 
getCookiesboolean getCookies()Return the "use cookies for session ids" flag.- Returns:
- trueif it is permitted to use cookies to track session IDs for this web application, otherwise- false
 
- 
setCookiesvoid setCookies(boolean cookies) Set the "use cookies for session ids" flag.- Parameters:
- cookies- The new flag
 
- 
getSessionCookieNameString 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
 
- 
setSessionCookieNameSets the name to use for session cookies. Overrides any setting that may be specified by the application.- Parameters:
- sessionCookieName- The name to use
 
- 
getUseHttpOnlyboolean getUseHttpOnly()Gets the value of the use HttpOnly cookies for session cookies flag.- Returns:
- trueif the HttpOnly flag should be set on session cookies
 
- 
setUseHttpOnlyvoid setUseHttpOnly(boolean useHttpOnly) Sets the use HttpOnly cookies for session cookies flag.- Parameters:
- useHttpOnly- Set to- trueto use HttpOnly cookies for session cookies
 
- 
getUsePartitionedboolean getUsePartitioned()Should thePartitionedattribute 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:
- trueif the- Partitionedattribute should be added to session cookies created for this web application, otherwise- false
 
- 
setUsePartitionedvoid setUsePartitioned(boolean usePartitioned) Configure whether thePartitionedattribute 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-- trueif the- Partitionedattribute should be added to session cookies created for this web application, otherwise- false
 
- 
getSessionCookieDomainString 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
 
- 
setSessionCookieDomainSets the domain to use for session cookies. Overrides any setting that may be specified by the application.- Parameters:
- sessionCookieDomain- The domain to use
 
- 
getSessionCookiePathString 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
 
- 
setSessionCookiePathSets the path to use for session cookies. Overrides any setting that may be specified by the application.- Parameters:
- sessionCookiePath- The path to use
 
- 
getSessionCookiePathUsesTrailingSlashboolean 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:
- trueif the slash is added, otherwise- false
 
- 
setSessionCookiePathUsesTrailingSlashvoid 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-- trueif the slash is should be added, otherwise- false
 
- 
getCrossContextboolean getCrossContext()Return the "allow crossing servlet contexts" flag.- Returns:
- trueif cross-contest requests are allowed from this web applications, otherwise- false
 
- 
getAltDDNameString getAltDDName()Return the alternate Deployment Descriptor name.- Returns:
- the name
 
- 
setAltDDNameSet an alternate Deployment Descriptor name.- Parameters:
- altDDName- The new name
 
- 
setCrossContextvoid setCrossContext(boolean crossContext) Set the "allow crossing servlet contexts" flag.- Parameters:
- crossContext- The new cross contexts flag
 
- 
getDenyUncoveredHttpMethodsboolean getDenyUncoveredHttpMethods()Return the deny-uncovered-http-methods flag for this web application.- Returns:
- The current value of the flag
 
- 
setDenyUncoveredHttpMethodsvoid setDenyUncoveredHttpMethods(boolean denyUncoveredHttpMethods) Set the deny-uncovered-http-methods flag for this web application.- Parameters:
- denyUncoveredHttpMethods- The new deny-uncovered-http-methods flag
 
- 
getDisplayNameString getDisplayName()Return the display name of this web application.- Returns:
- The display name
 
- 
setDisplayNameSet the display name of this web application.- Parameters:
- displayName- The new display name
 
- 
getDistributableboolean getDistributable()Get the distributable flag for this web application.- Returns:
- The value of the distributable flag for this web application.
 
- 
setDistributablevoid setDistributable(boolean distributable) Set the distributable flag for this web application.- Parameters:
- distributable- The new distributable flag
 
- 
getDocBaseString getDocBase()Obtain the document root for this Context.- Returns:
- An absolute pathname or a relative (to the Host's appBase) pathname.
 
- 
setDocBaseSet 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
 
- 
getEncodedPathString getEncodedPath()Return the URL encoded context path- Returns:
- The URL encoded (with UTF-8) context path
 
- 
getIgnoreAnnotationsboolean getIgnoreAnnotations()Determine if annotations parsing is currently disabled- Returns:
- trueif annotation parsing is disabled for this web application
 
- 
setIgnoreAnnotationsvoid setIgnoreAnnotations(boolean ignoreAnnotations) Set the boolean on the annotations parsing for this web application.- Parameters:
- ignoreAnnotations- The boolean on the annotations parsing
 
- 
getLoginConfigLoginConfig getLoginConfig()- Returns:
- the login configuration descriptor for this web application.
 
- 
setLoginConfigSet the login configuration descriptor for this web application.- Parameters:
- config- The new login configuration
 
- 
getNamingResourcesNamingResourcesImpl getNamingResources()- Returns:
- the naming resources associated with this web application.
 
- 
setNamingResourcesSet the naming resources for this web application.- Parameters:
- namingResources- The new naming resources
 
- 
getPathString getPath()- Returns:
- the context path for this web application.
 
- 
setPathSet the context path for this web application.- Parameters:
- path- The new context path
 
- 
getPublicIdString getPublicId()- Returns:
- the public identifier of the deployment descriptor DTD that is currently being parsed.
 
- 
setPublicIdSet the public identifier of the deployment descriptor DTD that is currently being parsed.- Parameters:
- publicId- The public identifier
 
- 
getReloadableboolean getReloadable()- Returns:
- the reloadable flag for this web application.
 
- 
setReloadablevoid setReloadable(boolean reloadable) Set the reloadable flag for this web application.- Parameters:
- reloadable- The new reloadable flag
 
- 
getOverrideboolean getOverride()- Returns:
- the override flag for this web application.
 
- 
setOverridevoid setOverride(boolean override) Set the override flag for this web application.- Parameters:
- override- The new override flag
 
- 
getPrivilegedboolean getPrivileged()- Returns:
- the privileged flag for this web application.
 
- 
setPrivilegedvoid setPrivileged(boolean privileged) Set the privileged flag for this web application.- Parameters:
- privileged- The new privileged flag
 
- 
getServletContextServletContext getServletContext()- Returns:
- the Servlet context for which this Context is a facade.
 
- 
getSessionTimeoutint getSessionTimeout()- Returns:
- the default session timeout (in minutes) for this web application.
 
- 
setSessionTimeoutvoid setSessionTimeout(int timeout) Set the default session timeout (in minutes) for this web application.- Parameters:
- timeout- The new default session timeout
 
- 
getSwallowAbortedUploadsboolean getSwallowAbortedUploads()Returnstrueif remaining request data will be read (swallowed) even the request violates a data size constraint.- Returns:
- trueif data will be swallowed (default),- falseotherwise.
 
- 
setSwallowAbortedUploadsvoid setSwallowAbortedUploads(boolean swallowAbortedUploads) Set tofalseto disable request data swallowing after an upload was aborted due to size constraints.- Parameters:
- swallowAbortedUploads-- falseto disable swallowing,- trueotherwise (default).
 
- 
getSwallowOutputboolean getSwallowOutput()- Returns:
- the value of the swallowOutput flag.
 
- 
setSwallowOutputvoid 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
 
- 
getWrapperClassString getWrapperClass()- Returns:
- the Java class name of the Wrapper implementation used for servlets registered in this Context.
 
- 
setWrapperClassSet the Java class name of the Wrapper implementation used for servlets registered in this Context.- Parameters:
- wrapperClass- The new wrapper class
 
- 
getXmlNamespaceAwareboolean 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.
 
- 
setXmlNamespaceAwarevoid 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
 
- 
getXmlValidationboolean 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.
 
- 
setXmlValidationvoid 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
 
- 
getXmlBlockExternalboolean 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
 
- 
setXmlBlockExternalvoid 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
 
- 
getTldValidationboolean getTldValidation()Will the parsing of *.tld files for this Context be performed by a validating parser?- Returns:
- true if validation is enabled.
 
- 
setTldValidationvoid 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
 
- 
getJarScannerJarScanner getJarScanner()Get the Jar Scanner to be used to scan for JAR resources for this context.- Returns:
- The Jar Scanner configured for this context.
 
- 
setJarScannerSet 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.
 
- 
getAuthenticatorAuthenticator getAuthenticator()- Returns:
- the Authenticatorthat is used by this context. This is always non-nullfor a started Context
 
- 
setLogEffectiveWebXmlvoid setLogEffectiveWebXml(boolean logEffectiveWebXml) Set whether or not the effective web.xml for this context should be logged on context start.- Parameters:
- logEffectiveWebXml- set to- trueto log the complete web.xml that will be used for the webapp
 
- 
getLogEffectiveWebXmlboolean 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
 
- 
getInstanceManagerInstanceManager getInstanceManager()- Returns:
- the instance manager associated with this context.
 
- 
setInstanceManagerSet the instance manager associated with this context.- Parameters:
- instanceManager- the new instance manager instance
 
- 
setContainerSciFilterSets 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
 
- 
getContainerSciFilterString 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
 
- 
isParallelAnnotationScanningDeprecated.This method will be removed in Tomcat 11 onwards- Returns:
- the value of the parallel annotation scanning flag. If true, it will dispatch scanning to the utility executor.
 
- 
getParallelAnnotationScanningboolean getParallelAnnotationScanning()- Returns:
- the value of the parallel annotation scanning flag. If true, it will dispatch scanning to the utility executor.
 
- 
setParallelAnnotationScanningvoid setParallelAnnotationScanning(boolean parallelAnnotationScanning) Set the parallel annotation scanning value.- Parameters:
- parallelAnnotationScanning- new parallel annotation scanning flag
 
- 
addApplicationListenerAdd a new Listener class name to the set of Listeners configured for this application.- Parameters:
- listener- Java class name of a listener class
 
- 
addApplicationParameterAdd a new application parameter for this application.- Parameters:
- parameter- The new application parameter
 
- 
addConstraintAdd a security constraint to the set for this web application.- Parameters:
- constraint- The security constraint that should be added
 
- 
addErrorPageAdd an error page for the specified error or Java exception.- Parameters:
- errorPage- The error page definition to be added
 
- 
addFilterDefAdd a filter definition to this Context.- Parameters:
- filterDef- The filter definition to be added
 
- 
addFilterMapAdd a filter mapping to this Context.- Parameters:
- filterMap- The filter mapping to be added
 
- 
addFilterMapBeforeAdd 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
 
- 
addLocaleEncodingMappingParameterAdd 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
 
- 
addMimeMappingAdd a new MIME mapping, replacing any existing mapping for the specified extension.- Parameters:
- extension- Filename extension being mapped
- mimeType- Corresponding MIME type
 
- 
addParameterAdd 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
 
- 
addRoleMappingAdd a security role reference for this web application.- Parameters:
- role- Security role used in the application
- link- Actual security role to check for
 
- 
addSecurityRoleAdd a new security role for this web application.- Parameters:
- role- New security role
 
- 
addServletMappingDecodedAdd 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
 
- 
addServletMappingDecodedAdd 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
 
- 
addWatchedResourceAdd 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
 
- 
addWelcomeFileAdd a new welcome file to the set recognized by this Context.- Parameters:
- name- New welcome file name
 
- 
addWrapperLifecycleAdd the classname of a LifecycleListener to be added to each Wrapper appended to this Context.- Parameters:
- listener- Java class name of a LifecycleListener class
 
- 
addWrapperListenerAdd the classname of a ContainerListener to be added to each Wrapper appended to this Context.- Parameters:
- listener- Java class name of a ContainerListener class
 
- 
createInstanceManagerInstanceManager 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
 
- 
createWrapperWrapper 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
 
- 
findApplicationListenersString[] findApplicationListeners()- Returns:
- the set of application listener class names configured for this application.
 
- 
findApplicationParametersApplicationParameter[] findApplicationParameters()- Returns:
- the set of application parameters for this application.
 
- 
findConstraintsSecurityConstraint[] 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.
 
- 
findErrorPageFind 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.
 
- 
findErrorPagesErrorPage[] findErrorPages()- Returns:
- the set of defined error pages for all specified error codes and exception types.
 
- 
findFilterDef- Parameters:
- filterName- Filter name to look up
- Returns:
- the filter definition for the specified filter name, if any;
 otherwise return null.
 
- 
findFilterDefsFilterDef[] findFilterDefs()- Returns:
- the set of defined filters for this Context.
 
- 
findFilterMapsFilterMap[] findFilterMaps()- Returns:
- the set of filter mappings for this Context.
 
- 
findMimeMapping- Parameters:
- extension- Extension to map to a MIME type
- Returns:
- the MIME type to which the specified extension is mapped,
 if any; otherwise return null.
 
- 
findMimeMappingsString[] findMimeMappings()- Returns:
- the extensions for which MIME mappings are defined. If there are none, a zero-length array is returned.
 
- 
findParameter- Parameters:
- name- Name of the parameter to return
- Returns:
- the value for the specified context initialization
 parameter name, if any; otherwise return null.
 
- 
findParametersString[] findParameters()- Returns:
- the names of all defined context initialization parameters for this Context. If no parameters are defined, a zero-length array is returned.
 
- 
findRoleMappingFor 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:
- trueif the specified security role is defined for this application; otherwise return- false.
 
- 
findSecurityRolesString[] findSecurityRoles()- Returns:
- the security roles defined for this application. If none have been defined, a zero-length array is returned.
 
- 
findServletMapping- Parameters:
- pattern- Pattern for which a mapping is requested
- Returns:
- the servlet name mapped by the specified pattern (if any);
 otherwise return null.
 
- 
findServletMappingsString[] findServletMappings()- Returns:
- the patterns of all defined servlet mappings for this Context. If no mappings are defined, a zero-length array is returned.
 
- 
getThreadBindingListenerThreadBindingListener getThreadBindingListener()- Returns:
- the associated ThreadBindingListener.
 
- 
setThreadBindingListenerGet the associated ThreadBindingListener.- Parameters:
- threadBindingListener- Set the listener that will receive notifications when entering and exiting the application scope
 
- 
findWatchedResourcesString[] 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:
- trueif the specified welcome file is defined for this Context; otherwise return- false.
 
- 
findWelcomeFilesString[] findWelcomeFiles()- Returns:
- the set of welcome files defined for this Context. If none are defined, a zero-length array is returned.
 
- 
findWrapperLifecyclesString[] findWrapperLifecycles()- Returns:
- the set of LifecycleListener classes that will be added to newly created Wrappers automatically.
 
- 
findWrapperListenersString[] findWrapperListeners()- Returns:
- the set of ContainerListener classes that will be added to newly created Wrappers automatically.
 
- 
fireRequestInitEventNotify allServletRequestListeners that a request has started.- Parameters:
- request- The request object that will be passed to the listener
- Returns:
- trueif the listeners fire successfully, else- false
 
- 
fireRequestDestroyEventNotify allServletRequestListeners that a request has ended.- Parameters:
- request- The request object that will be passed to the listener
- Returns:
- trueif the listeners fire successfully, else- false
 
- 
reloadvoid reload()Reload this web application, if reloading is supported.- Throws:
- IllegalStateException- if the- reloadableproperty is set to- false.
 
- 
removeApplicationListenerRemove the specified application listener class from the set of listeners for this application.- Parameters:
- listener- Java class name of the listener to be removed
 
- 
removeApplicationParameterRemove the application parameter with the specified name from the set for this application.- Parameters:
- name- Name of the application parameter to remove
 
- 
removeConstraintRemove the specified security constraint from this web application.- Parameters:
- constraint- Constraint to be removed
 
- 
removeErrorPageRemove 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
 
- 
removeFilterDefRemove the specified filter definition from this Context, if it exists; otherwise, no action is taken.- Parameters:
- filterDef- Filter definition to be removed
 
- 
removeFilterMapRemove a filter mapping from this Context.- Parameters:
- filterMap- The filter mapping to be removed
 
- 
removeMimeMappingRemove the MIME mapping for the specified extension, if it exists; otherwise, no action is taken.- Parameters:
- extension- Extension to remove the mapping for
 
- 
removeParameterRemove the context initialization parameter with the specified name, if it exists; otherwise, no action is taken.- Parameters:
- name- Name of the parameter to remove
 
- 
removeRoleMappingRemove any security role reference for the specified name- Parameters:
- role- Security role (as used in the application) to remove
 
- 
removeSecurityRoleRemove any security role with the specified name.- Parameters:
- role- Security role to remove
 
- 
removeServletMappingRemove any servlet mapping for the specified pattern, if it exists; otherwise, no action is taken.- Parameters:
- pattern- URL pattern of the mapping to remove
 
- 
removeWatchedResourceRemove the specified watched resource name from the list associated with this Context.- Parameters:
- name- Name of the watched resource to be removed
 
- 
removeWelcomeFileRemove the specified welcome file name from the list recognized by this Context.- Parameters:
- name- Name of the welcome file to be removed
 
- 
removeWrapperLifecycleRemove 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
 
- 
removeWrapperListenerRemove 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- Parameters:
- path- The path to the desired resource
- Returns:
- the real path for a given virtual path, if possible; otherwise
 return null.
 
- 
getEffectiveMajorVersionint getEffectiveMajorVersion()- Returns:
- the effective major version of the Servlet spec used by this context.
 
- 
setEffectiveMajorVersionvoid setEffectiveMajorVersion(int major) Set the effective major version of the Servlet spec used by this context.- Parameters:
- major- Set the version number
 
- 
getEffectiveMinorVersionint getEffectiveMinorVersion()- Returns:
- the effective minor version of the Servlet spec used by this context.
 
- 
setEffectiveMinorVersionvoid setEffectiveMinorVersion(int minor) Set the effective minor version of the Servlet spec used by this context.- Parameters:
- minor- Set the version number
 
- 
getJspConfigDescriptorJspConfigDescriptor getJspConfigDescriptor()- Returns:
- the JSP configuration for this context. Will be null if there is no JSP configuration.
 
- 
setJspConfigDescriptorSet the JspConfigDescriptor for this context. A null value indicates there is not JSP configuration.- Parameters:
- descriptor- the new JSP configuration
 
- 
addServletContainerInitializerAdd a ServletContainerInitializer instance to this web application.- Parameters:
- sci- The instance to add
- classes- The classes in which the initializer expressed an interest
 
- 
getPausedboolean getPaused()Is this Context paused whilst it is reloaded?- Returns:
- trueif the context has been paused
 
- 
isServlet22boolean isServlet22()Is this context using version 2.2 of the Servlet spec?- Returns:
- truefor a legacy Servlet 2.2 webapp
 
- 
addServletSecuritySet<String> addServletSecurity(ServletRegistration.Dynamic registration, ServletSecurityElement servletSecurityElement) Notification that Servlet security has been dynamically set in aServletRegistration.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
 
- 
setResourceOnlyServletsSets 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
 
- 
getResourceOnlyServletsString 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
 
- 
isResourceOnlyServletChecks 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:
- trueif the Servlet expects a resource, otherwise- false
 
- 
getBaseNameString getBaseName()- Returns:
- the base name to use for WARs, directories or context.xml files for this context.
 
- 
setWebappVersionSet 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
 
- 
getWebappVersionString 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.
 
- 
setFireRequestListenersOnForwardsvoid setFireRequestListenersOnForwards(boolean enable) Configure whether or not requests listeners will be fired on forwards for this Context.- Parameters:
- enable-- trueto fire request listeners when forwarding
 
- 
getFireRequestListenersOnForwardsboolean getFireRequestListenersOnForwards()- Returns:
- whether or not requests listeners will be fired on forwards for this Context.
 
- 
setPreemptiveAuthenticationvoid 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-- trueto perform authentication even outside security constraints
 
- 
getPreemptiveAuthenticationboolean getPreemptiveAuthentication()- Returns:
- if a user presents authentication credentials, will the context will process them when the request is for a non-protected resource.
 
- 
setSendRedirectBodyvoid setSendRedirectBody(boolean enable) Configures if a response body is included when a redirect response is sent to the client.- Parameters:
- enable-- trueto send a response body for redirects
 
- 
getSendRedirectBodyboolean getSendRedirectBody()- Returns:
- if the context is configured to include a response body as part of a redirect response.
 
- 
getLoaderLoader getLoader()- Returns:
- the Loader with which this Context is associated.
 
- 
setLoaderSet the Loader with which this Context is associated.- Parameters:
- loader- The newly associated loader
 
- 
getResourcesWebResourceRoot getResources()- Returns:
- the Resources with which this Context is associated.
 
- 
setResourcesSet the Resources object with which this Context is associated.- Parameters:
- resources- The newly associated Resources
 
- 
getManagerManager getManager()- Returns:
- the Manager with which this Context is associated.  If there is
 no associated Manager, return null.
 
- 
setManagerSet the Manager with which this Context is associated.- Parameters:
- manager- The newly associated Manager
 
- 
setAddWebinfClassesResourcesvoid 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
 
- 
getAddWebinfClassesResourcesboolean 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.
 
- 
addPostConstructMethodAdd 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 name
- method- Post construct method name
- Throws:
- IllegalArgumentException- if the fully qualified class name or method name are- NULL; if there is already post construct method definition for the given class
 
- 
addPreDestroyMethodAdd 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 name
- method- Post construct method name
- Throws:
- IllegalArgumentException- if the fully qualified class name or method name are- NULL; if there is already pre destroy method definition for the given class
 
- 
removePostConstructMethodRemoves the post construct method definition for the given class, if it exists; otherwise, no action is taken.- Parameters:
- clazz- Fully qualified class name
 
- 
removePreDestroyMethodRemoves the pre destroy method definition for the given class, if it exists; otherwise, no action is taken.- Parameters:
- clazz- Fully qualified class name
 
- 
findPostConstructMethodReturns the method name that is specified as post construct method for the given class, if it exists; otherwiseNULLwill 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 NULLwill be returned.
 
- 
findPreDestroyMethodReturns the method name that is specified as pre destroy method for the given class, if it exists; otherwiseNULLwill 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 NULLwill be returned.
 
- 
findPostConstructMethodsReturns 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.
 
- 
findPreDestroyMethodsReturns 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.
 
- 
getNamingTokenObject getNamingToken()- Returns:
- the token necessary for operations on the associated JNDI naming context.
 
- 
setCookieProcessorSets theCookieProcessorthat will be used to process cookies for this Context.- Parameters:
- cookieProcessor- The new cookie processor
- Throws:
- IllegalArgumentException- If a- nullCookieProcessor is specified
 
- 
getCookieProcessorCookieProcessor getCookieProcessor()- Returns:
- the CookieProcessorthat will be used to process cookies for this Context.
 
- 
setValidateClientProvidedNewSessionIdvoid 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-- trueif validation should be applied
 
- 
getValidateClientProvidedNewSessionIdboolean getValidateClientProvidedNewSessionId()Will client provided session IDs be validated (seesetValidateClientProvidedNewSessionId(boolean)) before use?- Returns:
- trueif validation will be applied. Otherwise,- false
 
- 
setMapperContextRootRedirectEnabledvoid 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?
 
- 
getMapperContextRootRedirectEnabledboolean 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:
- trueif the Mapper level redirect is enabled for this Context.
 
- 
setMapperDirectoryRedirectEnabledvoid 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?
 
- 
getMapperDirectoryRedirectEnabledboolean 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:
- trueif the Mapper level redirect is enabled for this Context.
 
- 
setUseRelativeRedirectsvoid 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 RemoteIpFilterif the filter is changing the scheme and/or port.- Parameters:
- useRelativeRedirects-- trueto use relative redirects and- falseto use absolute redirects
 
- 
getUseRelativeRedirectsboolean getUseRelativeRedirects()Will HTTP 1.1 and later location headers generated by a call toHttpServletResponse.sendRedirect(String)use relative or absolute redirects.- Returns:
- trueif relative redirects will be used- falseif absolute redirects are used.
- See Also:
 
- 
setDispatchersUseEncodedPathsvoid 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-- trueto use encoded paths, otherwise- false
 
- 
getDispatchersUseEncodedPathsboolean 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:
- trueif encoded paths will be used, otherwise- false
 
- 
setRequestCharacterEncodingSet the default request body encoding for this web application.- Parameters:
- encoding- The default encoding
 
- 
getRequestCharacterEncodingString getRequestCharacterEncoding()Get the default request body encoding for this web application.- Returns:
- The default request body encoding
 
- 
setResponseCharacterEncodingSet the default response body encoding for this web application.- Parameters:
- encoding- The default encoding
 
- 
getResponseCharacterEncodingString getResponseCharacterEncoding()Get the default response body encoding for this web application.- Returns:
- The default response body encoding
 
- 
setAllowMultipleLeadingForwardSlashInPathvoid 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
 
- 
getAllowMultipleLeadingForwardSlashInPathboolean getAllowMultipleLeadingForwardSlashInPath()When returning a context path fromHttpServletRequest.getContextPath(), is it allowed to contain multiple leading '/' characters?- Returns:
- trueif multiple leading '/' characters are allowed, otherwise- false
 
- 
incrementInProgressAsyncCountvoid incrementInProgressAsyncCount()
- 
decrementInProgressAsyncCountvoid decrementInProgressAsyncCount()
- 
setCreateUploadTargetsvoid 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-- trueif Tomcat should attempt to create the upload target, otherwise- false
 
- 
getCreateUploadTargetsboolean 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:
- trueif Tomcat will attempt to create an upload target otherwise- false
 
- 
getAlwaysAccessSessionboolean 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_COMPLIANCEis set totrue, the default of this setting will betrue, else the default value will befalse.- Returns:
- the flag value
 
- 
setAlwaysAccessSessionvoid setAlwaysAccessSession(boolean alwaysAccessSession) Set the session access behavior.- Parameters:
- alwaysAccessSession- the new flag value
 
- 
getContextGetResourceRequiresSlashboolean getContextGetResourceRequiresSlash()If this istruethen 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_COMPLIANCEis set totrue, the default of this setting will betrue, else the default value will befalse.- Returns:
- the flag value
 
- 
setContextGetResourceRequiresSlashvoid setContextGetResourceRequiresSlash(boolean contextGetResourceRequiresSlash) Allow usingServletContext.getResource()orServletContext.getResourceAsStream()without a leading "/".- Parameters:
- contextGetResourceRequiresSlash- the new flag value
 
- 
getDispatcherWrapsSameObjectboolean getDispatcherWrapsSameObject()If this istruethen 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_COMPLIANCEis set totrue, the default of this setting will betrue, else the default value will befalse.- Returns:
- the flag value
 
- 
setDispatcherWrapsSameObjectvoid setDispatcherWrapsSameObject(boolean dispatcherWrapsSameObject) Allow disabling the object wrap check in the request dispatcher.- Parameters:
- dispatcherWrapsSameObject- the new flag value
 
- 
findConfigFileResourceFind configuration file with the specified path, first looking into the webapp resources, then delegating toConfigFileLoader.getSource().getResource. TheWEBAPP_PROTOCOLconstant 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
 
- 
getUseBloomFilterForArchivesDeprecated.This method will be removed in Tomcat 11 onwards. UseWebResourceRoot.getArchiveIndexStrategy()- Returns:
- trueif the resources archive lookup will use a bloom filter.
 
- 
setUseBloomFilterForArchivesDeprecated.This method will be removed in Tomcat 11 onwards UseWebResourceRoot.setArchiveIndexStrategy(String)Set bloom filter flag value.- Parameters:
- useBloomFilterForArchives- The new fast class path scan flag
 
 
-