Package org.apache.catalina
Interface Context
-
- All Superinterfaces:
Container,ContextBind,Lifecycle
- All Known Implementing Classes:
FailedContext,ReplicatedContext,StandardContext
public interface Context extends Container, ContextBind
A Context is a Container that represents a servlet context, and therefore an individual web application, in the Catalina servlet engine. It is therefore useful in almost every deployment of Catalina (even if a Connector attached to a web server (such as Apache) uses the web server's facilities to identify the appropriate Wrapper to handle this request. It also provides a convenient mechanism to use Interceptors that see every request processed by this particular web application.The parent Container attached to a Context is generally a Host, but may be some other implementation, or may be omitted if it is not necessary.
The child containers attached to a Context are generally implementations of Wrapper (representing individual servlet definitions).
- Author:
- Craig R. McClanahan
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.catalina.Lifecycle
Lifecycle.SingleUse
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringADD_WELCOME_FILE_EVENTContainer event for adding a welcome file.static java.lang.StringCHANGE_SESSION_ID_EVENTContainer event for changing the ID of a session.static java.lang.StringCLEAR_WELCOME_FILES_EVENTContainer event for clearing welcome files.static java.lang.StringREMOVE_WELCOME_FILE_EVENTContainer event for removing a wrapper.-
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
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description voidaddApplicationListener(java.lang.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(java.lang.String locale, java.lang.String encoding)Add a Locale Encoding Mapping (see Sec 5.4 of Servlet spec 2.4)voidaddMimeMapping(java.lang.String extension, java.lang.String mimeType)Add a new MIME mapping, replacing any existing mapping for the specified extension.voidaddParameter(java.lang.String name, java.lang.String value)Add a new context initialization parameter, replacing any existing value for the specified name.voidaddPostConstructMethod(java.lang.String clazz, java.lang.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(java.lang.String clazz, java.lang.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(java.lang.String role, java.lang.String link)Add a security role reference for this web application.voidaddSecurityRole(java.lang.String role)Add a new security role for this web application.voidaddServletContainerInitializer(ServletContainerInitializer sci, java.util.Set<java.lang.Class<?>> classes)Add a ServletContainerInitializer instance to this web application.default voidaddServletMappingDecoded(java.lang.String pattern, java.lang.String name)Add a new servlet mapping, replacing any existing mapping for the specified pattern.voidaddServletMappingDecoded(java.lang.String pattern, java.lang.String name, boolean jspWildcard)Add a new servlet mapping, replacing any existing mapping for the specified pattern.java.util.Set<java.lang.String>addServletSecurity(ServletRegistration.Dynamic registration, ServletSecurityElement servletSecurityElement)Notification that Servlet security has been dynamically set in aServletRegistration.DynamicvoidaddWatchedResource(java.lang.String name)Add a resource which will be watched for reloading by the host auto deployer.voidaddWelcomeFile(java.lang.String name)Add a new welcome file to the set recognized by this Context.voidaddWrapperLifecycle(java.lang.String listener)Add the classname of a LifecycleListener to be added to each Wrapper appended to this Context.voidaddWrapperListener(java.lang.String listener)Add the classname of a ContainerListener to be added to each Wrapper appended to this Context.InstanceManagercreateInstanceManager()Factory method to create and return a new InstanceManager instance.WrappercreateWrapper()Factory method to create and return a new Wrapper instance, of the Java implementation class appropriate for this Context implementation.voiddecrementInProgressAsyncCount()java.lang.String[]findApplicationListeners()ApplicationParameter[]findApplicationParameters()SecurityConstraint[]findConstraints()ErrorPagefindErrorPage(int errorCode)ErrorPagefindErrorPage(java.lang.String exceptionType)Deprecated.Unused.ErrorPagefindErrorPage(java.lang.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.ErrorPage[]findErrorPages()FilterDeffindFilterDef(java.lang.String filterName)FilterDef[]findFilterDefs()FilterMap[]findFilterMaps()java.lang.StringfindMimeMapping(java.lang.String extension)java.lang.String[]findMimeMappings()java.lang.StringfindParameter(java.lang.String name)java.lang.String[]findParameters()java.lang.StringfindPostConstructMethod(java.lang.String clazz)Returns the method name that is specified as post construct method for the given class, if it exists; otherwiseNULLwill be returned.java.util.Map<java.lang.String,java.lang.String>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.java.lang.StringfindPreDestroyMethod(java.lang.String clazz)Returns the method name that is specified as pre destroy method for the given class, if it exists; otherwiseNULLwill be returned.java.util.Map<java.lang.String,java.lang.String>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.java.lang.StringfindRoleMapping(java.lang.String role)For the given security role (as used by an application), return the corresponding role name (as defined by the underlying Realm) if there is one.booleanfindSecurityRole(java.lang.String role)java.lang.String[]findSecurityRoles()java.lang.StringfindServletMapping(java.lang.String pattern)java.lang.String[]findServletMappings()java.lang.StringfindStatusPage(int status)Deprecated.Unused.int[]findStatusPages()Deprecated.Unused.java.lang.String[]findWatchedResources()booleanfindWelcomeFile(java.lang.String name)java.lang.String[]findWelcomeFiles()java.lang.String[]findWrapperLifecycles()java.lang.String[]findWrapperListeners()booleanfireRequestDestroyEvent(ServletRequest request)Notify allServletRequestListeners that a request has ended.booleanfireRequestInitEvent(ServletRequest request)Notify allServletRequestListeners that a request has started.booleangetAddWebinfClassesResources()booleangetAllowCasualMultipartParsing()Returnstrueif requests mapped to servlets without "multipart config" to parse multipart/form-data requests anyway.booleangetAllowMultipleLeadingForwardSlashInPath()When returning a context path fromHttpServletRequest.getContextPath(), is it allowed to contain multiple leading '/' characters?java.lang.StringgetAltDDName()Return the alternate Deployment Descriptor name.java.lang.Object[]getApplicationEventListeners()Obtain the registered application event listeners.java.lang.Object[]getApplicationLifecycleListeners()Obtain the registered application lifecycle listeners.AuthenticatorgetAuthenticator()java.lang.StringgetBaseName()java.lang.StringgetCharset(java.util.Locale locale)Obtain the character set name to use with the given Locale.java.net.URLgetConfigFile()Return the URL of the XML descriptor for this context.booleangetConfigured()Return the "correctly configured" flag for this Context.java.lang.StringgetContainerSciFilter()Obtains the regular expression that specifies which container provided SCIs should be filtered out and not used for this context.CookieProcessorgetCookieProcessor()booleangetCookies()Return the "use cookies for session ids" flag.booleangetCreateUploadTargets()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?booleangetCrossContext()Return the "allow crossing servlet contexts" flag.booleangetDenyUncoveredHttpMethods()Return the deny-uncovered-http-methods flag for this web application.booleangetDispatchersUseEncodedPaths()Are paths used in calls to obtain a request dispatcher expected to be encoded?java.lang.StringgetDisplayName()Return the display name of this web application.booleangetDistributable()Get the distributable flag for this web application.java.lang.StringgetDocBase()Obtain the document root for this Context.intgetEffectiveMajorVersion()intgetEffectiveMinorVersion()java.lang.StringgetEncodedPath()Return the URL encoded context pathbooleangetFireRequestListenersOnForwards()booleangetIgnoreAnnotations()Determine if annotations parsing is currently disabledInstanceManagergetInstanceManager()JarScannergetJarScanner()Get the Jar Scanner to be used to scan for JAR resources for this context.JspConfigDescriptorgetJspConfigDescriptor()LoadergetLoader()booleangetLogEffectiveWebXml()Should the effective web.xml for this context be logged on context start?LoginConfiggetLoginConfig()ManagergetManager()booleangetMapperContextRootRedirectEnabled()Determines if requests for a web application context root will be redirected (adding a trailing slash) by the Mapper.booleangetMapperDirectoryRedirectEnabled()Determines if requests for a directory will be redirected (adding a trailing slash) by the Mapper.NamingResourcesImplgetNamingResources()java.lang.ObjectgetNamingToken()booleangetOverride()booleangetParallelAnnotationScanning()java.lang.StringgetPath()booleangetPaused()Is this Context paused whilst it is reloaded?booleangetPreemptiveAuthentication()booleangetPrivileged()java.lang.StringgetPublicId()java.lang.StringgetRealPath(java.lang.String path)booleangetReloadable()java.lang.StringgetRequestCharacterEncoding()Get the default request body encoding for this web application.java.lang.StringgetResourceOnlyServlets()Obtains the list of Servlets that expect a resource to be present.WebResourceRootgetResources()java.lang.StringgetResponseCharacterEncoding()Get the default response body encoding for this web application.booleangetSendRedirectBody()ServletContextgetServletContext()java.lang.StringgetSessionCookieDomain()Gets the domain to use for session cookies.java.lang.StringgetSessionCookieName()Gets the name to use for session cookies.java.lang.StringgetSessionCookiePath()Gets the path to use for session cookies.booleangetSessionCookiePathUsesTrailingSlash()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.intgetSessionTimeout()booleangetSwallowAbortedUploads()Returnstrueif remaining request data will be read (swallowed) even the request violates a data size constraint.booleangetSwallowOutput()ThreadBindingListenergetThreadBindingListener()booleangetTldValidation()Will the parsing of *.tld files for this Context be performed by a validating parser?booleangetUseBloomFilterForArchives()booleangetUseHttpOnly()Gets the value of the use HttpOnly cookies for session cookies flag.booleangetUseRelativeRedirects()Will HTTP 1.1 and later location headers generated by a call toHttpServletResponse.sendRedirect(String)use relative or absolute redirects.booleangetValidateClientProvidedNewSessionId()Will client provided session IDs be validated (seesetValidateClientProvidedNewSessionId(boolean)) before use?java.lang.StringgetWebappVersion()java.lang.StringgetWrapperClass()booleangetXmlBlockExternal()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?booleangetXmlNamespaceAware()Will the parsing of web.xml and web-fragment.xml files for this Context be performed by a namespace aware parser?booleangetXmlValidation()Will the parsing of web.xml and web-fragment.xml files for this Context be performed by a validating parser?voidincrementInProgressAsyncCount()default booleanisParallelAnnotationScanning()Deprecated.This method will be removed in Tomcat 11 onwardsbooleanisResourceOnlyServlet(java.lang.String servletName)Checks the named Servlet to see if it expects a resource to be present.booleanisServlet22()Is this context using version 2.2 of the Servlet spec?voidreload()Reload this web application, if reloading is supported.voidremoveApplicationListener(java.lang.String listener)Remove the specified application listener class from the set of listeners for this application.voidremoveApplicationParameter(java.lang.String name)Remove 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(java.lang.String extension)Remove the MIME mapping for the specified extension, if it exists; otherwise, no action is taken.voidremoveParameter(java.lang.String name)Remove the context initialization parameter with the specified name, if it exists; otherwise, no action is taken.voidremovePostConstructMethod(java.lang.String clazz)Removes the post construct method definition for the given class, if it exists; otherwise, no action is taken.voidremovePreDestroyMethod(java.lang.String clazz)Removes the pre destroy method definition for the given class, if it exists; otherwise, no action is taken.voidremoveRoleMapping(java.lang.String role)Remove any security role reference for the specified namevoidremoveSecurityRole(java.lang.String role)Remove any security role with the specified name.voidremoveServletMapping(java.lang.String pattern)Remove any servlet mapping for the specified pattern, if it exists; otherwise, no action is taken.voidremoveWatchedResource(java.lang.String name)Remove the specified watched resource name from the list associated with this Context.voidremoveWelcomeFile(java.lang.String name)Remove the specified welcome file name from the list recognized by this Context.voidremoveWrapperLifecycle(java.lang.String listener)Remove a class name from the set of LifecycleListener classes that will be added to newly created Wrappers.voidremoveWrapperListener(java.lang.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(java.lang.String altDDName)Set an alternate Deployment Descriptor name.voidsetApplicationEventListeners(java.lang.Object[] listeners)Store the set of initialized application event listener objects, in the order they were specified in the web application deployment descriptor, for this application.voidsetApplicationLifecycleListeners(java.lang.Object[] listeners)Store the set of initialized application lifecycle listener objects, in the order they were specified in the web application deployment descriptor, for this application.voidsetConfigFile(java.net.URL configFile)Set the URL of the XML descriptor for this context.voidsetConfigured(boolean configured)Set the "correctly configured" flag for this Context.voidsetContainerSciFilter(java.lang.String containerSciFilter)Sets the regular expression that specifies which container provided SCIs should be filtered out and not used for this context.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?voidsetDisplayName(java.lang.String displayName)Set the display name of this web application.voidsetDistributable(boolean distributable)Set the distributable flag for this web application.voidsetDocBase(java.lang.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.voidsetLoader(Loader loader)Set 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.voidsetPath(java.lang.String path)Set 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(java.lang.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(java.lang.String encoding)Set the default request body encoding for this web application.voidsetResourceOnlyServlets(java.lang.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(java.lang.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(java.lang.String sessionCookieDomain)Sets the domain to use for session cookies.voidsetSessionCookieName(java.lang.String sessionCookieName)Sets the name to use for session cookies.voidsetSessionCookiePath(java.lang.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)Set bloom filter flag value.voidsetUseHttpOnly(boolean useHttpOnly)Sets the use HttpOnly cookies for session cookies flag.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(java.lang.String webappVersion)Set the version of this web application - used to differentiate different versions of the same web application when using parallel deployment.voidsetWrapperClass(java.lang.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.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, unbind
-
Methods inherited from interface org.apache.catalina.Lifecycle
addLifecycleListener, destroy, findLifecycleListeners, getState, getStateName, init, removeLifecycleListener, start, stop
-
-
-
-
Field Detail
-
ADD_WELCOME_FILE_EVENT
static final java.lang.String ADD_WELCOME_FILE_EVENT
Container event for adding a welcome file.- See Also:
- Constant Field Values
-
REMOVE_WELCOME_FILE_EVENT
static final java.lang.String REMOVE_WELCOME_FILE_EVENT
Container event for removing a wrapper.- See Also:
- Constant Field Values
-
CLEAR_WELCOME_FILES_EVENT
static final java.lang.String CLEAR_WELCOME_FILES_EVENT
Container event for clearing welcome files.- See Also:
- Constant Field Values
-
CHANGE_SESSION_ID_EVENT
static final java.lang.String CHANGE_SESSION_ID_EVENT
Container event for changing the ID of a session.- See Also:
- Constant Field Values
-
-
Method Detail
-
getAllowCasualMultipartParsing
boolean 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.
-
setAllowCasualMultipartParsing
void 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.
-
getApplicationEventListeners
java.lang.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
void setApplicationEventListeners(java.lang.Object[] listeners)
Store the set of initialized application event listener objects, in the order they were specified in the web application deployment descriptor, for this application.- Parameters:
listeners- The set of instantiated listener objects.
-
getApplicationLifecycleListeners
java.lang.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
void setApplicationLifecycleListeners(java.lang.Object[] listeners)
Store the set of initialized application lifecycle listener objects, in the order they were specified in the web application deployment descriptor, for this application.- Parameters:
listeners- The set of instantiated listener objects.
-
getCharset
java.lang.String getCharset(java.util.Locale locale)
Obtain the character set name to use with the given Locale. Note that different Contexts may have different mappings of Locale to character set.- 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
java.net.URL getConfigFile()
Return the URL of the XML descriptor for this context.- Returns:
- The URL of the XML descriptor for this context
-
setConfigFile
void setConfigFile(java.net.URL configFile)
Set the URL of the XML descriptor for this context.- Parameters:
configFile- The URL of the XML descriptor for this context.
-
getConfigured
boolean getConfigured()
Return the "correctly configured" flag for this Context.- Returns:
trueif 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:
trueif 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
java.lang.String getSessionCookieName()
Gets the name to use for session cookies. Overrides any setting that may be specified by the application.- Returns:
- The value of the default session cookie name or null if not specified
-
setSessionCookieName
void setSessionCookieName(java.lang.String sessionCookieName)
Sets the name to use for session cookies. Overrides any setting that may be specified by the application.- Parameters:
sessionCookieName- The name to use
-
getUseHttpOnly
boolean getUseHttpOnly()
Gets the value of the use HttpOnly cookies for session cookies flag.- Returns:
trueif 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 totrueto use HttpOnly cookies for session cookies
-
getSessionCookieDomain
java.lang.String getSessionCookieDomain()
Gets the domain to use for session cookies. Overrides any setting that may be specified by the application.- Returns:
- The value of the default session cookie domain or null if not specified
-
setSessionCookieDomain
void setSessionCookieDomain(java.lang.String sessionCookieDomain)
Sets the domain to use for session cookies. Overrides any setting that may be specified by the application.- Parameters:
sessionCookieDomain- The domain to use
-
getSessionCookiePath
java.lang.String getSessionCookiePath()
Gets the path to use for session cookies. Overrides any setting that may be specified by the application.- Returns:
- The value of the default session cookie path or null if not specified
-
setSessionCookiePath
void setSessionCookiePath(java.lang.String sessionCookiePath)
Sets the path to use for session cookies. Overrides any setting that may be specified by the application.- Parameters:
sessionCookiePath- The path to use
-
getSessionCookiePathUsesTrailingSlash
boolean getSessionCookiePathUsesTrailingSlash()
Is a / added to the end of the session cookie path to ensure browsers, particularly IE, don't send a session cookie for context /foo with requests intended for context /foobar.- Returns:
trueif 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-trueif the slash is should be added, otherwisefalse
-
getCrossContext
boolean getCrossContext()
Return the "allow crossing servlet contexts" flag.- Returns:
trueif cross-contest requests are allowed from this web applications, otherwisefalse
-
getAltDDName
java.lang.String getAltDDName()
Return the alternate Deployment Descriptor name.- Returns:
- the name
-
setAltDDName
void setAltDDName(java.lang.String altDDName)
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
java.lang.String getDisplayName()
Return the display name of this web application.- Returns:
- The display name
-
setDisplayName
void setDisplayName(java.lang.String displayName)
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
java.lang.String getDocBase()
Obtain the document root for this Context.- Returns:
- An absolute pathname or a relative (to the Host's appBase) pathname.
-
setDocBase
void setDocBase(java.lang.String docBase)
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
java.lang.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:
trueif 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
-
getLoginConfig
LoginConfig getLoginConfig()
- Returns:
- the login configuration descriptor for this web application.
-
setLoginConfig
void setLoginConfig(LoginConfig config)
Set the login configuration descriptor for this web application.- Parameters:
config- The new login configuration
-
getNamingResources
NamingResourcesImpl getNamingResources()
- Returns:
- the naming resources associated with this web application.
-
setNamingResources
void setNamingResources(NamingResourcesImpl namingResources)
Set the naming resources for this web application.- Parameters:
namingResources- The new naming resources
-
getPath
java.lang.String getPath()
- Returns:
- the context path for this web application.
-
setPath
void setPath(java.lang.String path)
Set the context path for this web application.- Parameters:
path- The new context path
-
getPublicId
java.lang.String getPublicId()
- Returns:
- the public identifier of the deployment descriptor DTD that is currently being parsed.
-
setPublicId
void setPublicId(java.lang.String publicId)
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()
Returnstrueif remaining request data will be read (swallowed) even the request violates a data size constraint.- Returns:
trueif data will be swallowed (default),falseotherwise.
-
setSwallowAbortedUploads
void 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).
-
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
java.lang.String getWrapperClass()
- Returns:
- the Java class name of the Wrapper implementation used for servlets registered in this Context.
-
setWrapperClass
void setWrapperClass(java.lang.String wrapperClass)
Set the Java class name of the Wrapper implementation used for servlets registered in this Context.- Parameters:
wrapperClass- The new wrapper class
-
getXmlNamespaceAware
boolean getXmlNamespaceAware()
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
void setJarScanner(JarScanner jarScanner)
Set the Jar Scanner to be used to scan for JAR resources for this context.- Parameters:
jarScanner- The Jar Scanner to be used for this context.
-
getAuthenticator
Authenticator getAuthenticator()
- Returns:
- the
Authenticatorthat is used by this context. This is always non-nullfor 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 totrueto 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
void setInstanceManager(InstanceManager instanceManager)
Set the instance manager associated with this context.- Parameters:
instanceManager- the new instance manager instance
-
setContainerSciFilter
void setContainerSciFilter(java.lang.String containerSciFilter)
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
java.lang.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
-
isParallelAnnotationScanning
@Deprecated default boolean isParallelAnnotationScanning()
Deprecated.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.
-
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
void addApplicationListener(java.lang.String listener)
Add a new Listener class name to the set of Listeners configured for this application.- Parameters:
listener- Java class name of a listener class
-
addApplicationParameter
void addApplicationParameter(ApplicationParameter parameter)
Add a new application parameter for this application.- Parameters:
parameter- The new application parameter
-
addConstraint
void addConstraint(SecurityConstraint constraint)
Add a security constraint to the set for this web application.- Parameters:
constraint- The security constraint that should be added
-
addErrorPage
void addErrorPage(ErrorPage errorPage)
Add an error page for the specified error or Java exception.- Parameters:
errorPage- The error page definition to be added
-
addFilterDef
void addFilterDef(FilterDef filterDef)
Add a filter definition to this Context.- Parameters:
filterDef- The filter definition to be added
-
addFilterMap
void addFilterMap(FilterMap filterMap)
Add a filter mapping to this Context.- Parameters:
filterMap- The filter mapping to be added
-
addFilterMapBefore
void addFilterMapBefore(FilterMap filterMap)
Add a filter mapping to this Context before the mappings defined in the deployment descriptor but after any other mappings added via this method.- Parameters:
filterMap- The filter mapping to be added- Throws:
java.lang.IllegalArgumentException- if the specified filter name does not match an existing filter definition, or the filter mapping is malformed
-
addLocaleEncodingMappingParameter
void addLocaleEncodingMappingParameter(java.lang.String locale, java.lang.String encoding)Add a Locale Encoding Mapping (see Sec 5.4 of Servlet spec 2.4)- Parameters:
locale- locale to map an encoding forencoding- encoding to be used for a give locale
-
addMimeMapping
void addMimeMapping(java.lang.String extension, java.lang.String mimeType)Add a new MIME mapping, replacing any existing mapping for the specified extension.- Parameters:
extension- Filename extension being mappedmimeType- Corresponding MIME type
-
addParameter
void addParameter(java.lang.String name, java.lang.String value)Add a new context initialization parameter, replacing any existing value for the specified name.- Parameters:
name- Name of the new parametervalue- Value of the new parameter
-
addRoleMapping
void addRoleMapping(java.lang.String role, java.lang.String link)Add a security role reference for this web application.- Parameters:
role- Security role used in the applicationlink- Actual security role to check for
-
addSecurityRole
void addSecurityRole(java.lang.String role)
Add a new security role for this web application.- Parameters:
role- New security role
-
addServletMappingDecoded
default void addServletMappingDecoded(java.lang.String pattern, java.lang.String name)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 execute
-
addServletMappingDecoded
void addServletMappingDecoded(java.lang.String pattern, java.lang.String name, boolean jspWildcard)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
void addWatchedResource(java.lang.String name)
Add a resource which will be watched for reloading by the host auto deployer. Note: this will not be used in embedded mode.- Parameters:
name- Path to the resource, relative to docBase
-
addWelcomeFile
void addWelcomeFile(java.lang.String name)
Add a new welcome file to the set recognized by this Context.- Parameters:
name- New welcome file name
-
addWrapperLifecycle
void addWrapperLifecycle(java.lang.String listener)
Add the classname of a LifecycleListener to be added to each Wrapper appended to this Context.- Parameters:
listener- Java class name of a LifecycleListener class
-
addWrapperListener
void addWrapperListener(java.lang.String listener)
Add the classname of a ContainerListener to be added to each Wrapper appended to this Context.- Parameters:
listener- Java class name of a ContainerListener class
-
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
java.lang.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
ErrorPage findErrorPage(int errorCode)
- Parameters:
errorCode- Error code to look up- Returns:
- the error page entry for the specified HTTP error code,
if any; otherwise return
null.
-
findErrorPage
@Deprecated ErrorPage findErrorPage(java.lang.String exceptionType)
Deprecated.Unused. Will be removed in Tomcat 10. UsefindErrorPage(Throwable)instead.- Parameters:
exceptionType- Exception type to look up- Returns:
- the error page entry for the specified Java exception type,
if any; otherwise return
null.
-
findErrorPage
ErrorPage findErrorPage(java.lang.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. 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
FilterDef findFilterDef(java.lang.String filterName)
- Parameters:
filterName- Filter name to look up- Returns:
- the filter definition for the specified filter name, if any;
otherwise return
null.
-
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
java.lang.String findMimeMapping(java.lang.String extension)
- 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.
-
findMimeMappings
java.lang.String[] findMimeMappings()
- Returns:
- the extensions for which MIME mappings are defined. If there are none, a zero-length array is returned.
-
findParameter
java.lang.String findParameter(java.lang.String name)
- Parameters:
name- Name of the parameter to return- Returns:
- the value for the specified context initialization
parameter name, if any; otherwise return
null.
-
findParameters
java.lang.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
java.lang.String findRoleMapping(java.lang.String role)
For the given security role (as used by an application), return the corresponding role name (as defined by the underlying Realm) if there is one. Otherwise, return the specified role unchanged.- Parameters:
role- Security role to map- Returns:
- The role name that was mapped to the specified role
-
findSecurityRole
boolean findSecurityRole(java.lang.String role)
- Parameters:
role- Security role to verify- Returns:
trueif the specified security role is defined for this application; otherwise returnfalse.
-
findSecurityRoles
java.lang.String[] findSecurityRoles()
- Returns:
- the security roles defined for this application. If none have been defined, a zero-length array is returned.
-
findServletMapping
java.lang.String findServletMapping(java.lang.String pattern)
- Parameters:
pattern- Pattern for which a mapping is requested- Returns:
- the servlet name mapped by the specified pattern (if any);
otherwise return
null.
-
findServletMappings
java.lang.String[] findServletMappings()
- Returns:
- the patterns of all defined servlet mappings for this Context. If no mappings are defined, a zero-length array is returned.
-
findStatusPage
@Deprecated java.lang.String findStatusPage(int status)
Deprecated.Unused. Will be removed in Tomcat 10. UsefindErrorPage(int)instead.- Parameters:
status- HTTP status code to look up- Returns:
- the context-relative URI of the error page for the specified
HTTP status code, if any; otherwise return
null.
-
findStatusPages
@Deprecated int[] findStatusPages()
Deprecated.Unused. Will be removed in Tomcat 10. UsefindErrorPages()instead.- Returns:
- the set of HTTP status codes for which error pages have been specified. If none are specified, a zero-length array is returned.
-
getThreadBindingListener
ThreadBindingListener getThreadBindingListener()
- Returns:
- the associated ThreadBindingListener.
-
setThreadBindingListener
void setThreadBindingListener(ThreadBindingListener threadBindingListener)
Get the associated ThreadBindingListener.- Parameters:
threadBindingListener- Set the listener that will receive notifications when entering and exiting the application scope
-
findWatchedResources
java.lang.String[] findWatchedResources()
- Returns:
- the set of watched resources for this Context. If none are defined, a zero length array will be returned.
-
findWelcomeFile
boolean findWelcomeFile(java.lang.String name)
- Parameters:
name- Welcome file to verify- Returns:
trueif the specified welcome file is defined for this Context; otherwise returnfalse.
-
findWelcomeFiles
java.lang.String[] findWelcomeFiles()
- Returns:
- the set of welcome files defined for this Context. If none are defined, a zero-length array is returned.
-
findWrapperLifecycles
java.lang.String[] findWrapperLifecycles()
- Returns:
- the set of LifecycleListener classes that will be added to newly created Wrappers automatically.
-
findWrapperListeners
java.lang.String[] findWrapperListeners()
- Returns:
- the set of ContainerListener classes that will be added to newly created Wrappers automatically.
-
fireRequestInitEvent
boolean fireRequestInitEvent(ServletRequest request)
Notify allServletRequestListeners that a request has started.- Parameters:
request- The request object that will be passed to the listener- Returns:
trueif the listeners fire successfully, elsefalse
-
fireRequestDestroyEvent
boolean fireRequestDestroyEvent(ServletRequest request)
Notify allServletRequestListeners that a request has ended.- Parameters:
request- The request object that will be passed to the listener- Returns:
trueif the listeners fire successfully, elsefalse
-
reload
void reload()
Reload this web application, if reloading is supported.- Throws:
java.lang.IllegalStateException- if thereloadableproperty is set tofalse.
-
removeApplicationListener
void removeApplicationListener(java.lang.String listener)
Remove the specified application listener class from the set of listeners for this application.- Parameters:
listener- Java class name of the listener to be removed
-
removeApplicationParameter
void removeApplicationParameter(java.lang.String name)
Remove the application parameter with the specified name from the set for this application.- Parameters:
name- Name of the application parameter to remove
-
removeConstraint
void removeConstraint(SecurityConstraint constraint)
Remove the specified security constraint from this web application.- Parameters:
constraint- Constraint to be removed
-
removeErrorPage
void removeErrorPage(ErrorPage errorPage)
Remove the error page for the specified error code or Java language exception, if it exists; otherwise, no action is taken.- Parameters:
errorPage- The error page definition to be removed
-
removeFilterDef
void removeFilterDef(FilterDef filterDef)
Remove the specified filter definition from this Context, if it exists; otherwise, no action is taken.- Parameters:
filterDef- Filter definition to be removed
-
removeFilterMap
void removeFilterMap(FilterMap filterMap)
Remove a filter mapping from this Context.- Parameters:
filterMap- The filter mapping to be removed
-
removeMimeMapping
void removeMimeMapping(java.lang.String extension)
Remove the MIME mapping for the specified extension, if it exists; otherwise, no action is taken.- Parameters:
extension- Extension to remove the mapping for
-
removeParameter
void removeParameter(java.lang.String name)
Remove the context initialization parameter with the specified name, if it exists; otherwise, no action is taken.- Parameters:
name- Name of the parameter to remove
-
removeRoleMapping
void removeRoleMapping(java.lang.String role)
Remove any security role reference for the specified name- Parameters:
role- Security role (as used in the application) to remove
-
removeSecurityRole
void removeSecurityRole(java.lang.String role)
Remove any security role with the specified name.- Parameters:
role- Security role to remove
-
removeServletMapping
void removeServletMapping(java.lang.String pattern)
Remove any servlet mapping for the specified pattern, if it exists; otherwise, no action is taken.- Parameters:
pattern- URL pattern of the mapping to remove
-
removeWatchedResource
void removeWatchedResource(java.lang.String name)
Remove the specified watched resource name from the list associated with this Context.- Parameters:
name- Name of the watched resource to be removed
-
removeWelcomeFile
void removeWelcomeFile(java.lang.String name)
Remove the specified welcome file name from the list recognized by this Context.- Parameters:
name- Name of the welcome file to be removed
-
removeWrapperLifecycle
void removeWrapperLifecycle(java.lang.String listener)
Remove a class name from the set of LifecycleListener classes that will be added to newly created Wrappers.- Parameters:
listener- Class name of a LifecycleListener class to be removed
-
removeWrapperListener
void removeWrapperListener(java.lang.String listener)
Remove a class name from the set of ContainerListener classes that will be added to newly created Wrappers.- Parameters:
listener- Class name of a ContainerListener class to be removed
-
getRealPath
java.lang.String getRealPath(java.lang.String path)
- Parameters:
path- The path to the desired resource- Returns:
- the real path for a given virtual path, if possible; otherwise
return
null.
-
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
void setJspConfigDescriptor(JspConfigDescriptor descriptor)
Set the JspConfigDescriptor for this context. A null value indicates there is not JSP configuration.- Parameters:
descriptor- the new JSP configuration
-
addServletContainerInitializer
void addServletContainerInitializer(ServletContainerInitializer sci, java.util.Set<java.lang.Class<?>> classes)
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:
trueif the context has been paused
-
isServlet22
boolean isServlet22()
Is this context using version 2.2 of the Servlet spec?- Returns:
truefor a legacy Servlet 2.2 webapp
-
addServletSecurity
java.util.Set<java.lang.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
void setResourceOnlyServlets(java.lang.String resourceOnlyServlets)
Sets the (comma separated) list of Servlets that expect a resource to be present. Used to ensure that welcome files associated with Servlets that expect a resource to be present are not mapped when there is no resource.- Parameters:
resourceOnlyServlets- The Servlet names comma separated list
-
getResourceOnlyServlets
java.lang.String getResourceOnlyServlets()
Obtains the list of Servlets that expect a resource to be present.- Returns:
- A comma separated list of Servlet names as used in web.xml
-
isResourceOnlyServlet
boolean isResourceOnlyServlet(java.lang.String servletName)
Checks the named Servlet to see if it expects a resource to be present.- Parameters:
servletName- Name of the Servlet (as per web.xml) to check- Returns:
trueif the Servlet expects a resource, otherwisefalse
-
getBaseName
java.lang.String getBaseName()
- Returns:
- the base name to use for WARs, directories or context.xml files for this context.
-
setWebappVersion
void setWebappVersion(java.lang.String webappVersion)
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
java.lang.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-trueto 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-trueto 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-trueto 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
void setLoader(Loader loader)
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
void setResources(WebResourceRoot resources)
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
void setManager(Manager manager)
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
void addPostConstructMethod(java.lang.String clazz, java.lang.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.- Parameters:
clazz- Fully qualified class namemethod- Post construct method name- Throws:
java.lang.IllegalArgumentException- if the fully qualified class name or method name areNULL; if there is already post construct method definition for the given class
-
addPreDestroyMethod
void addPreDestroyMethod(java.lang.String clazz, java.lang.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.- Parameters:
clazz- Fully qualified class namemethod- Post construct method name- Throws:
java.lang.IllegalArgumentException- if the fully qualified class name or method name areNULL; if there is already pre destroy method definition for the given class
-
removePostConstructMethod
void removePostConstructMethod(java.lang.String clazz)
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
void removePreDestroyMethod(java.lang.String clazz)
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
java.lang.String findPostConstructMethod(java.lang.String clazz)
Returns 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.
-
findPreDestroyMethod
java.lang.String findPreDestroyMethod(java.lang.String clazz)
Returns 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.
-
findPostConstructMethods
java.util.Map<java.lang.String,java.lang.String> 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
java.util.Map<java.lang.String,java.lang.String> 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
java.lang.Object getNamingToken()
- Returns:
- the token necessary for operations on the associated JNDI naming context.
-
setCookieProcessor
void setCookieProcessor(CookieProcessor cookieProcessor)
Sets theCookieProcessorthat will be used to process cookies for this Context.- Parameters:
cookieProcessor- The new cookie processor- Throws:
java.lang.IllegalArgumentException- If anullCookieProcessor is specified
-
getCookieProcessor
CookieProcessor getCookieProcessor()
- Returns:
- the
CookieProcessorthat 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-trueif validation should be applied
-
getValidateClientProvidedNewSessionId
boolean getValidateClientProvidedNewSessionId()
Will client provided session IDs be validated (seesetValidateClientProvidedNewSessionId(boolean)) before use?- Returns:
trueif 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:
trueif 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:
trueif 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
RemoteIpFilterif the filter is changing the scheme and/or port.- Parameters:
useRelativeRedirects-trueto use relative redirects andfalseto 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:
trueif relative redirects will be usedfalseif absolute redirects are used.- See Also:
setUseRelativeRedirects(boolean)
-
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-trueto 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:
trueif encoded paths will be used, otherwisefalse
-
setRequestCharacterEncoding
void setRequestCharacterEncoding(java.lang.String encoding)
Set the default request body encoding for this web application.- Parameters:
encoding- The default encoding
-
getRequestCharacterEncoding
java.lang.String getRequestCharacterEncoding()
Get the default request body encoding for this web application.- Returns:
- The default request body encoding
-
setResponseCharacterEncoding
void setResponseCharacterEncoding(java.lang.String encoding)
Set the default response body encoding for this web application.- Parameters:
encoding- The default encoding
-
getResponseCharacterEncoding
java.lang.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:
trueif 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-trueif 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:
trueif Tomcat will attempt to create an upload target otherwisefalse
-
getUseBloomFilterForArchives
boolean getUseBloomFilterForArchives()
- Returns:
trueif the resources archive lookup will use a bloom filter.
-
setUseBloomFilterForArchives
void setUseBloomFilterForArchives(boolean useBloomFilterForArchives)
Set bloom filter flag value.- Parameters:
useBloomFilterForArchives- The new fast class path scan flag
-
-