Top Description Fields Methods
org.apache.catalina

public Interface Context

extends Container, ContextBind
Known Direct Implementers
org.apache.catalina.core.StandardContext, org.apache.catalina.startup.FailedContext
Imports
java.io.FileNotFoundException, .IOException, .InputStream, java.net.URISyntaxException, .URL, java.util.Locale, .Map, .Set, jakarta.servlet.ServletContainerInitializer, .ServletContext, .ServletRegistration, .ServletRequest, .ServletSecurityElement, jakarta.servlet.descriptor.JspConfigDescriptor, org.apache.catalina.deploy.NamingResourcesImpl, org.apache.tomcat.ContextBind, .InstanceManager, .JarScanner, org.apache.tomcat.util.descriptor.web.ApplicationParameter, .ErrorPage, .FilterDef, .FilterMap, .LoginConfig, .SecurityConstraint, org.apache.tomcat.util.file.ConfigFileLoader, .ConfigurationSource.Resource, org.apache.tomcat.util.http.CookieProcessor

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

Field Summary

Modifier and TypeField and Description
public static final String
ADD_WELCOME_FILE_EVENT

Container event for adding a welcome file.

public static final String
CHANGE_SESSION_ID_EVENT

Container event for changing the ID of a session.

public static final String
CLEAR_WELCOME_FILES_EVENT

Container event for clearing welcome files.

public static final String
REMOVE_WELCOME_FILE_EVENT

Container event for removing a wrapper.

public static final String
WEBAPP_PROTOCOL

Prefix for resource lookup.

Inherited from org.apache.catalina.Container:
ADD_CHILD_EVENTADD_VALVE_EVENTREMOVE_CHILD_EVENTREMOVE_VALVE_EVENT

Method Summary

Modifier and TypeMethod and Description
public void
addApplicationListener(String
Java class name of a listener class
listener
)

Add a new Listener class name to the set of Listeners configured for this application.

public void
addApplicationParameter(ApplicationParameter
The new application parameter
parameter
)

Add a new application parameter for this application.

public void
addConstraint(SecurityConstraint
The security constraint that should be added
constraint
)

Add a security constraint to the set for this web application.

public void
addErrorPage(ErrorPage
The error page definition to be added
errorPage
)

Add an error page for the specified error or Java exception.

public void
addFilterDef(FilterDef
The filter definition to be added
filterDef
)

Add a filter definition to this Context.

public void
addFilterMap(FilterMap
The filter mapping to be added
filterMap
)

Add a filter mapping to this Context.

public void
addFilterMapBefore(FilterMap
The filter mapping to be added
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.

public void
addLocaleEncodingMappingParameter(String
locale to map an encoding for
locale
,
String
encoding to be used for a give locale
encoding
)

Add a Locale Encoding Mapping (see Sec 5.4 of Servlet spec 2.4)

public void
addMimeMapping(String
Filename extension being mapped
extension
,
String
Corresponding MIME type
mimeType
)

Add a new MIME mapping, replacing any existing mapping for the specified extension.

public void
addParameter(String
Name of the new parameter
name
,
String
Value of the new parameter
value
)

Add a new context initialization parameter, replacing any existing value for the specified name.

public void
addPostConstructMethod(String
Fully qualified class name
clazz
,
String
Post construct method name
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.

public void
addPreDestroyMethod(String
Fully qualified class name
clazz
,
String
Post construct method name
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.

public void
addRoleMapping(String
Security role used in the application
role
,
String
Actual security role to check for
link
)

Add a security role reference for this web application.

public void
addSecurityRole(String
New security role
role
)

Add a new security role for this web application.

public void
addServletContainerInitializer(ServletContainerInitializer
The instance to add
sci
,
Set<Class<?>>
The classes in which the initializer expressed an interest
classes
)

Add a ServletContainerInitializer instance to this web application.

public default void
addServletMappingDecoded(String
URL pattern to be mapped
pattern
,
String
Name of the corresponding servlet to execute
name
)

Add a new servlet mapping, replacing any existing mapping for the specified pattern.

public void
addServletMappingDecoded(String
URL pattern to be mapped
pattern
,
String
Name of the corresponding servlet to execute
name
,
boolean
true if name identifies the JspServlet and pattern contains a wildcard; false otherwise
jspWildcard
)

Add a new servlet mapping, replacing any existing mapping for the specified pattern.

public Set<String>

Returns:

urls currently mapped to this registration that are already present in web.xml
addServletSecurity
(ServletRegistration.Dynamic
Servlet security was modified for
registration
,
ServletSecurityElement
new security constraints for this Servlet
servletSecurityElement
)

Notification that Servlet security has been dynamically set in a jakarta.servlet.ServletRegistration.Dynamic

public void
addWatchedResource(String
Path to the resource, relative to docBase
name
)

Add a resource which will be watched for reloading by the host auto deployer.

public void
addWelcomeFile(String
New welcome file name
name
)

Add a new welcome file to the set recognized by this Context.

public void
addWrapperLifecycle(String
Java class name of a LifecycleListener class
listener
)

Add the classname of a LifecycleListener to be added to each Wrapper appended to this Context.

public void
addWrapperListener(String
Java class name of a ContainerListener class
listener
)

Add the classname of a ContainerListener to be added to each Wrapper appended to this Context.

public InstanceManager

Returns:

the instance manager
createInstanceManager
()

Factory method to create and return a new InstanceManager instance.

public Wrapper

Returns:

a newly created wrapper instance that is used to wrap a Servlet
createWrapper
()

Factory method to create and return a new Wrapper instance, of the Java implementation class appropriate for this Context implementation.

public void
public String[]

Returns:

the set of application listener class names configured for this application.
findApplicationListeners
()

public ApplicationParameter[]

Returns:

the set of application parameters for this application.
findApplicationParameters
()

public default ConfigurationSource.Resource

Returns:

the resource
findConfigFileResource
(String
The resource name
name
)

Find configuration file with the specified path, first looking into the webapp resources, then delegating to ConfigFileLoader.getSource().getResource.

public SecurityConstraint[]

Returns:

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

public ErrorPage

Returns:

the error page entry for the specified HTTP error code, if any; otherwise return null.
findErrorPage
(int
Error code to look up
errorCode
)

public ErrorPage

Returns:

the error page entry for the specified Java exception type, if any; otherwise return null.
findErrorPage
(Throwable
The exception type for which to find an ErrorPage
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.

public ErrorPage[]

Returns:

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

public FilterDef

Returns:

the filter definition for the specified filter name, if any; otherwise return null.
findFilterDef
(String
Filter name to look up
filterName
)

public FilterDef[]

Returns:

the set of defined filters for this Context.
findFilterDefs
()

public FilterMap[]

Returns:

the set of filter mappings for this Context.
findFilterMaps
()

public String

Returns:

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

public String[]

Returns:

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

public String

Returns:

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

public String[]

Returns:

the names of all defined context initialization parameters for this Context. If no parameters are defined, a zero-length array is returned.
findParameters
()

public String

Returns:

the method name that is specified as post construct method for the given class, if it exists; otherwise NULL will be returned.
findPostConstructMethod
(String
Fully qualified class name
clazz
)

Returns the method name that is specified as post construct method for the given class, if it exists; otherwise NULL will be returned.

public Map<String, String>

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.
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.

public String

Returns:

the method name that is specified as pre destroy method for the given class, if it exists; otherwise NULL will be returned.
findPreDestroyMethod
(String
Fully qualified class name
clazz
)

Returns the method name that is specified as pre destroy method for the given class, if it exists; otherwise NULL will be returned.

public Map<String, String>

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.
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.

public String

Returns:

The role name that was mapped to the specified role
findRoleMapping
(String
Security role to map
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.

public boolean

Returns:

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

public String[]

Returns:

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

public String

Returns:

the servlet name mapped by the specified pattern (if any); otherwise return null.
findServletMapping
(String
Pattern for which a mapping is requested
pattern
)

public String[]

Returns:

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

public String[]

Returns:

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

public boolean

Returns:

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

public String[]

Returns:

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

public String[]

Returns:

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

public String[]

Returns:

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

public boolean

Returns:

true if the listeners fire successfully, else false
fireRequestDestroyEvent
(ServletRequest
The request object that will be passed to the listener
request
)

Notify all jakarta.servlet.ServletRequestListeners that a request has ended.

public boolean

Returns:

true if the listeners fire successfully, else false
fireRequestInitEvent
(ServletRequest
The request object that will be passed to the listener
request
)

Notify all jakarta.servlet.ServletRequestListeners that a request has started.

public boolean

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.
getAddWebinfClassesResources
()

public boolean

Returns:

true if requests mapped to servlets without "multipart config" to parse multipart/form-data requests, false otherwise.
getAllowCasualMultipartParsing
()

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

public boolean

Returns:

true if multiple leading '/' characters are allowed, otherwise false
getAllowMultipleLeadingForwardSlashInPath
()

When returning a context path from jakarta.servlet.http.HttpServletRequest#getContextPath(), is it allowed to contain multiple leading '/' characters?

public String

Returns:

the name
getAltDDName
()

Return the alternate Deployment Descriptor name.

public boolean

Returns:

the flag value
getAlwaysAccessSession
()

If this is true, 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.

public Object[]

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
getApplicationEventListeners
()

Obtain the registered application event listeners.

public Object[]

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
getApplicationLifecycleListeners
()

Obtain the registered application lifecycle listeners.

public Authenticator

Returns:

the Authenticator that is used by this context. This is always non-null for a started Context
getAuthenticator
()

public String

Returns:

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

public String

Returns:

The name of the character set to use with the given Locale
getCharset
(Locale
The locale for which the mapped character set should be returned
locale
)

Obtain the character set name to use with the given Locale.

public URL

Returns:

The URL of the XML descriptor for this context
getConfigFile
()

Return the URL of the XML descriptor for this context.

public boolean

Returns:

true if the Context has been correctly configured, otherwise false
getConfigured
()

Return the "correctly configured" flag for this Context.

public String

Returns:

The regular expression against which the fully qualified class name of each container provided SCI will be checked
getContainerSciFilter
()

Obtains the regular expression that specifies which container provided SCIs should be filtered out and not used for this context.

public boolean

Returns:

the flag value
getContextGetResourceRequiresSlash
()

If this is true then the path passed to ServletContext.getResource() or ServletContext.getResourceAsStream() must start with "/".

public CookieProcessor

Returns:

the CookieProcessor that will be used to process cookies for this Context.
getCookieProcessor
()

public boolean

Returns:

true if it is permitted to use cookies to track session IDs for this web application, otherwise false
getCookies
()

Return the "use cookies for session ids" flag.

public boolean

Returns:

true if Tomcat will attempt to create an upload target otherwise false
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?

public boolean

Returns:

true if cross-contest requests are allowed from this web applications, otherwise false
getCrossContext
()

Return the "allow crossing servlet contexts" flag.

public boolean

Returns:

The current value of the flag
getDenyUncoveredHttpMethods
()

Return the deny-uncovered-http-methods flag for this web application.

public boolean

Returns:

true if encoded paths will be used, otherwise false
getDispatchersUseEncodedPaths
()

Are paths used in calls to obtain a request dispatcher expected to be encoded?

public boolean

Returns:

the flag value
getDispatcherWrapsSameObject
()

If this is true then any wrapped request or response object passed to an application dispatcher will be checked to ensure that it has wrapped the original request or response.

public String

Returns:

The display name
getDisplayName
()

Return the display name of this web application.

public boolean

Returns:

The value of the distributable flag for this web application.
getDistributable
()

Get the distributable flag for this web application.

public String

Returns:

An absolute pathname or a relative (to the Host's appBase) pathname.
getDocBase
()

Obtain the document root for this Context.

public int

Returns:

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

public int

Returns:

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

public String

Returns:

The URL encoded (with UTF-8) context path
getEncodedPath
()

Return the URL encoded context path

public boolean

Returns:

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

public boolean

Returns:

true if annotation parsing is disabled for this web application
getIgnoreAnnotations
()

Determine if annotations parsing is currently disabled

public InstanceManager

Returns:

the instance manager associated with this context.
getInstanceManager
()

public JarScanner

Returns:

The Jar Scanner configured for this context.
getJarScanner
()

Get the Jar Scanner to be used to scan for JAR resources for this context.

public JspConfigDescriptor

Returns:

the JSP configuration for this context. Will be null if there is no JSP configuration.
getJspConfigDescriptor
()

public Loader

Returns:

the Loader with which this Context is associated.
getLoader
()

public boolean

Returns:

true if the reconstructed web.xml that will be used for the webapp should be logged
getLogEffectiveWebXml
()

Should the effective web.xml for this context be logged on context start?

public LoginConfig

Returns:

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

public Manager

Returns:

the Manager with which this Context is associated. If there is no associated Manager, return null.
getManager
()

public boolean

Returns:

true if the Mapper level redirect is enabled for this Context.
getMapperContextRootRedirectEnabled
()

Determines if requests for a web application context root will be redirected (adding a trailing slash) by the Mapper.

public boolean

Returns:

true if the Mapper level redirect is enabled for this Context.
getMapperDirectoryRedirectEnabled
()

Determines if requests for a directory will be redirected (adding a trailing slash) by the Mapper.

public NamingResourcesImpl

Returns:

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

public Object

Returns:

the token necessary for operations on the associated JNDI naming context.
getNamingToken
()

public boolean

Returns:

the override flag for this web application.
getOverride
()

public boolean

Returns:

the value of the parallel annotation scanning flag. If true, it will dispatch scanning to the utility executor.
getParallelAnnotationScanning
()

public String

Returns:

the context path for this web application.
getPath
()

public boolean

Returns:

true if the context has been paused
getPaused
()

Is this Context paused whilst it is reloaded?

public boolean

Returns:

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

public boolean

Returns:

the privileged flag for this web application.
getPrivileged
()

public String

Returns:

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

public String

Returns:

the real path for a given virtual path, if possible; otherwise return null.
getRealPath
(String
The path to the desired resource
path
)

public boolean

Returns:

the reloadable flag for this web application.
getReloadable
()

public String

Returns:

The default request body encoding
getRequestCharacterEncoding
()

Get the default request body encoding for this web application.

public String

Returns:

A comma separated list of Servlet names as used in web.xml
getResourceOnlyServlets
()

Obtains the list of Servlets that expect a resource to be present.

public WebResourceRoot

Returns:

the Resources with which this Context is associated.
getResources
()

public String

Returns:

The default response body encoding
getResponseCharacterEncoding
()

Get the default response body encoding for this web application.

public boolean

Returns:

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

public ServletContext

Returns:

the Servlet context for which this Context is a facade.
getServletContext
()

public String

Returns:

The value of the default session cookie domain or null if not specified
getSessionCookieDomain
()

Gets the domain to use for session cookies.

public String

Returns:

The value of the default session cookie name or null if not specified
getSessionCookieName
()

Gets the name to use for session cookies.

public String

Returns:

The value of the default session cookie path or null if not specified
getSessionCookiePath
()

Gets the path to use for session cookies.

public boolean

Returns:

true if the slash is added, otherwise false
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.

public int

Returns:

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

public boolean

Returns:

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

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

public boolean

Returns:

the value of the swallowOutput flag.
getSwallowOutput
()

public ThreadBindingListener

Returns:

the associated ThreadBindingListener.
getThreadBindingListener
()

public boolean

Returns:

true if validation is enabled.
getTldValidation
()

Will the parsing of *.tld files for this Context be performed by a validating parser?

public boolean

Returns:

true if the resources archive lookup will use a bloom filter.
getUseBloomFilterForArchives
()
Deprecated This method will be removed in Tomcat 11 onwards. Use WebResourceRoot#getArchiveIndexStrategy()

public boolean

Returns:

true if the HttpOnly flag should be set on session cookies
getUseHttpOnly
()

Gets the value of the use HttpOnly cookies for session cookies flag.

public boolean

Returns:

true if the Partitioned attribute should be added to session cookies created for this web application, otherwise false
getUsePartitioned
()

Should the Partitioned attribute be added to session cookies created for this web application.

public boolean

Returns:

true if relative redirects will be used false if absolute redirects are used.
getUseRelativeRedirects
()

Will HTTP 1.1 and later location headers generated by a call to jakarta.servlet.http.HttpServletResponse#sendRedirect(String) use relative or absolute redirects.

public boolean

Returns:

true if validation will be applied. Otherwise, false
getValidateClientProvidedNewSessionId
()

Will client provided session IDs be validated (see setValidateClientProvidedNewSessionId(boolean)) before use?

public String

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.
getWebappVersion
()

public String

Returns:

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

public boolean

Returns:

true if access to external entities is blocked
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?

public boolean

Returns:

true if namespace awareness is enabled.
getXmlNamespaceAware
()

Will the parsing of web.xml and web-fragment.xml files for this Context be performed by a namespace aware parser?

public boolean

Returns:

true if validation is enabled.
getXmlValidation
()

Will the parsing of web.xml and web-fragment.xml files for this Context be performed by a validating parser?

public void
public default boolean

Returns:

the value of the parallel annotation scanning flag. If true, it will dispatch scanning to the utility executor.
isParallelAnnotationScanning
()
Deprecated This method will be removed in Tomcat 11 onwards

public boolean

Returns:

true if the Servlet expects a resource, otherwise false
isResourceOnlyServlet
(String
Name of the Servlet (as per web.xml) to check
servletName
)

Checks the named Servlet to see if it expects a resource to be present.

public boolean

Returns:

true for a legacy Servlet 2.2 webapp
isServlet22
()

Is this context using version 2.2 of the Servlet spec?

public void
reload()

Reload this web application, if reloading is supported.

public void
removeApplicationListener(String
Java class name of the listener to be removed
listener
)

Remove the specified application listener class from the set of listeners for this application.

public void
removeApplicationParameter(String
Name of the application parameter to remove
name
)

Remove the application parameter with the specified name from the set for this application.

public void
removeConstraint(SecurityConstraint
Constraint to be removed
constraint
)

Remove the specified security constraint from this web application.

public void
removeErrorPage(ErrorPage
The error page definition to be removed
errorPage
)

Remove the error page for the specified error code or Java language exception, if it exists; otherwise, no action is taken.

public void
removeFilterDef(FilterDef
Filter definition to be removed
filterDef
)

Remove the specified filter definition from this Context, if it exists; otherwise, no action is taken.

public void
removeFilterMap(FilterMap
The filter mapping to be removed
filterMap
)

Remove a filter mapping from this Context.

public void
removeMimeMapping(String
Extension to remove the mapping for
extension
)

Remove the MIME mapping for the specified extension, if it exists; otherwise, no action is taken.

public void
removeParameter(String
Name of the parameter to remove
name
)

Remove the context initialization parameter with the specified name, if it exists; otherwise, no action is taken.

public void
removePostConstructMethod(String
Fully qualified class name
clazz
)

Removes the post construct method definition for the given class, if it exists; otherwise, no action is taken.

public void
removePreDestroyMethod(String
Fully qualified class name
clazz
)

Removes the pre destroy method definition for the given class, if it exists; otherwise, no action is taken.

public void
removeRoleMapping(String
Security role (as used in the application) to remove
role
)

Remove any security role reference for the specified name

public void
removeSecurityRole(String
Security role to remove
role
)

Remove any security role with the specified name.

public void
removeServletMapping(String
URL pattern of the mapping to remove
pattern
)

Remove any servlet mapping for the specified pattern, if it exists; otherwise, no action is taken.

public void
removeWatchedResource(String
Name of the watched resource to be removed
name
)

Remove the specified watched resource name from the list associated with this Context.

public void
removeWelcomeFile(String
Name of the welcome file to be removed
name
)

Remove the specified welcome file name from the list recognized by this Context.

public void
removeWrapperLifecycle(String
Class name of a LifecycleListener class to be removed
listener
)

Remove a class name from the set of LifecycleListener classes that will be added to newly created Wrappers.

public void
removeWrapperListener(String
Class name of a ContainerListener class to be removed
listener
)

Remove a class name from the set of ContainerListener classes that will be added to newly created Wrappers.

public void
setAddWebinfClassesResources(boolean
The new value for the flag
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.

public void
setAllowCasualMultipartParsing(boolean
true to allow such casual parsing, false otherwise.
allowCasualMultipartParsing
)

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

public void
setAllowMultipleLeadingForwardSlashInPath(boolean
The new value for the flag
allowMultipleLeadingForwardSlashInPath
)

Configure if, when returning a context path from jakarta.servlet.http.HttpServletRequest#getContextPath(), the return value is allowed to contain multiple leading '/' characters.

public void
setAltDDName(String
The new name
altDDName
)

Set an alternate Deployment Descriptor name.

public void
setAlwaysAccessSession(boolean
the new flag value
alwaysAccessSession
)

Set the session access behavior.

public void
setApplicationEventListeners(Object[]
The set of instantiated listener objects.
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.

public void
setApplicationLifecycleListeners(Object[]
The set of instantiated listener objects.
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.

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

Set the URL of the XML descriptor for this context.

public void
setConfigured(boolean
The new correctly configured flag
configured
)

Set the "correctly configured" flag for this Context.

public void
setContainerSciFilter(String
The regular expression against which the fully qualified class name of each container provided SCI should be checked
containerSciFilter
)

Sets the regular expression that specifies which container provided SCIs should be filtered out and not used for this context.

public void
setContextGetResourceRequiresSlash(boolean
the new flag value
contextGetResourceRequiresSlash
)

Allow using ServletContext.getResource() or ServletContext.getResourceAsStream() without a leading "/".

public void
setCookieProcessor(CookieProcessor
The new cookie processor
cookieProcessor
)

Sets the CookieProcessor that will be used to process cookies for this Context.

public void
setCookies(boolean
The new flag
cookies
)

Set the "use cookies for session ids" flag.

public void
setCreateUploadTargets(boolean
true if Tomcat should attempt to create the upload target, otherwise false
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.

public void
setCrossContext(boolean
The new cross contexts flag
crossContext
)

Set the "allow crossing servlet contexts" flag.

public void
setDenyUncoveredHttpMethods(boolean
The new deny-uncovered-http-methods flag
denyUncoveredHttpMethods
)

Set the deny-uncovered-http-methods flag for this web application.

public void
setDispatchersUseEncodedPaths(boolean
true to use encoded paths, otherwise false
dispatchersUseEncodedPaths
)

Are paths used in calls to obtain a request dispatcher expected to be encoded?

public void
setDispatcherWrapsSameObject(boolean
the new flag value
dispatcherWrapsSameObject
)

Allow disabling the object wrap check in the request dispatcher.

public void
setDisplayName(String
The new display name
displayName
)

Set the display name of this web application.

public void
setDistributable(boolean
The new distributable flag
distributable
)

Set the distributable flag for this web application.

public void
setDocBase(String
The new document root
docBase
)

Set the document root for this Context.

public void
setEffectiveMajorVersion(int
Set the version number
major
)

Set the effective major version of the Servlet spec used by this context.

public void
setEffectiveMinorVersion(int
Set the version number
minor
)

Set the effective minor version of the Servlet spec used by this context.

public void
setFireRequestListenersOnForwards(boolean
true to fire request listeners when forwarding
enable
)

Configure whether or not requests listeners will be fired on forwards for this Context.

public void
setIgnoreAnnotations(boolean
The boolean on the annotations parsing
ignoreAnnotations
)

Set the boolean on the annotations parsing for this web application.

public void
setInstanceManager(InstanceManager
the new instance manager instance
instanceManager
)

Set the instance manager associated with this context.

public void
setJarScanner(JarScanner
The Jar Scanner to be used for this context.
jarScanner
)

Set the Jar Scanner to be used to scan for JAR resources for this context.

public void
setJspConfigDescriptor(JspConfigDescriptor
the new JSP configuration
descriptor
)

Set the JspConfigDescriptor for this context.

public void
setLoader(Loader
The newly associated loader
loader
)

Set the Loader with which this Context is associated.

public void
setLogEffectiveWebXml(boolean
set to true to log the complete web.xml that will be used for the webapp
logEffectiveWebXml
)

Set whether or not the effective web.xml for this context should be logged on context start.

public void
setLoginConfig(LoginConfig
The new login configuration
config
)

Set the login configuration descriptor for this web application.

public void
setManager(Manager
The newly associated Manager
manager
)

Set the Manager with which this Context is associated.

public void
setMapperContextRootRedirectEnabled(boolean
Should the redirects be enabled?
mapperContextRootRedirectEnabled
)

If enabled, requests for a web application context root will be redirected (adding a trailing slash) by the Mapper.

public void
setMapperDirectoryRedirectEnabled(boolean
Should the redirects be enabled?
mapperDirectoryRedirectEnabled
)

If enabled, requests for a directory will be redirected (adding a trailing slash) by the Mapper.

public void
setNamingResources(NamingResourcesImpl
The new naming resources
namingResources
)

Set the naming resources for this web application.

public void
setOverride(boolean
The new override flag
override
)

Set the override flag for this web application.

public void
setParallelAnnotationScanning(boolean
new parallel annotation scanning flag
parallelAnnotationScanning
)

Set the parallel annotation scanning value.

public void
setPath(String
The new context path
path
)

Set the context path for this web application.

public void
setPreemptiveAuthentication(boolean
true to perform authentication even outside security constraints
enable
)

Configures if a user presents authentication credentials, whether the context will process them when the request is for a non-protected resource.

public void
setPrivileged(boolean
The new privileged flag
privileged
)

Set the privileged flag for this web application.

public void
setPublicId(String
The public identifier
publicId
)

Set the public identifier of the deployment descriptor DTD that is currently being parsed.

public void
setReloadable(boolean
The new reloadable flag
reloadable
)

Set the reloadable flag for this web application.

public void
setRequestCharacterEncoding(String
The default encoding
encoding
)

Set the default request body encoding for this web application.

public void
setResourceOnlyServlets(String
The Servlet names comma separated list
resourceOnlyServlets
)

Sets the (comma separated) list of Servlets that expect a resource to be present.

public void
setResources(WebResourceRoot
The newly associated Resources
resources
)

Set the Resources object with which this Context is associated.

public void
setResponseCharacterEncoding(String
The default encoding
encoding
)

Set the default response body encoding for this web application.

public void
setSendRedirectBody(boolean
true to send a response body for redirects
enable
)

Configures if a response body is included when a redirect response is sent to the client.

public void
setSessionCookieDomain(String
The domain to use
sessionCookieDomain
)

Sets the domain to use for session cookies.

public void
setSessionCookieName(String
The name to use
sessionCookieName
)

Sets the name to use for session cookies.

public void
setSessionCookiePath(String
The path to use
sessionCookiePath
)

Sets the path to use for session cookies.

public void
setSessionCookiePathUsesTrailingSlash(boolean
true if the slash is should be added, otherwise false
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.

public void
setSessionTimeout(int
The new default session timeout
timeout
)

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

public void
setSwallowAbortedUploads(boolean
false to disable swallowing, true otherwise (default).
swallowAbortedUploads
)

Set to false to disable request data swallowing after an upload was aborted due to size constraints.

public void
setSwallowOutput(boolean
The new value
swallowOutput
)

Set the value of the swallowOutput flag.

public void
setThreadBindingListener(ThreadBindingListener
Set the listener that will receive notifications when entering and exiting the application scope
threadBindingListener
)

Get the associated ThreadBindingListener.

public void
setTldValidation(boolean
true to enable xml validation
tldValidation
)

Controls whether the parsing of *.tld files for this Context will be performed by a validating parser.

public void
setUseBloomFilterForArchives(boolean
The new fast class path scan flag
useBloomFilterForArchives
)
Deprecated This method will be removed in Tomcat 11 onwards Use WebResourceRoot#setArchiveIndexStrategy(String)

Set bloom filter flag value.

public void
setUseHttpOnly(boolean
Set to true to use HttpOnly cookies for session cookies
useHttpOnly
)

Sets the use HttpOnly cookies for session cookies flag.

public void
setUsePartitioned(boolean
true if the Partitioned attribute should be added to session cookies created for this web application, otherwise false
usePartitioned
)

Configure whether the Partitioned attribute should be added to session cookies created for this web application.

public void
setUseRelativeRedirects(boolean
true to use relative redirects and false to use absolute redirects
useRelativeRedirects
)

Controls whether HTTP 1.1 and later location headers generated by a call to jakarta.servlet.http.HttpServletResponse#sendRedirect(String) will use relative or absolute redirects.

public void
setValidateClientProvidedNewSessionId(boolean
true if validation should be applied
validateClientProvidedNewSessionId
)

When a client provides the ID for a new session, should that ID be validated?

public void
setWebappVersion(String
The webapp version associated with the context, which should be unique
webappVersion
)

Set the version of this web application - used to differentiate different versions of the same web application when using parallel deployment.

public void
setWrapperClass(String
The new wrapper class
wrapperClass
)

Set the Java class name of the Wrapper implementation used for servlets registered in this Context.

public void
setXmlBlockExternal(boolean
true to block external entities
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.

public void
setXmlNamespaceAware(boolean
true to enable namespace awareness
xmlNamespaceAware
)

Controls whether the parsing of web.xml and web-fragment.xml files for this Context will be performed by a namespace aware parser.

public void
setXmlValidation(boolean
true to enable xml validation
xmlValidation
)

Controls whether the parsing of web.xml and web-fragment.xml files for this Context will be performed by a validating parser.

Inherited from org.apache.catalina.Container:
addChildaddContainerListeneraddPropertyChangeListenerbackgroundProcessfindChildfindChildrenfindContainerListenersfireContainerEventgetAccessLoggetBackgroundProcessorDelaygetCatalinaBasegetCatalinaHomegetClustergetConfigPathgetDomaingetLoggergetLogNamegetMBeanKeyPropertiesgetNamegetObjectNamegetParentgetParentClassLoadergetPipelinegetRealmgetServicegetStartStopThreadslogAccessremoveChildremoveContainerListenerremovePropertyChangeListenersetBackgroundProcessorDelaysetClustersetNamesetParentsetParentClassLoadersetRealmsetStartStopThreads
Inherited from org.apache.tomcat.ContextBind:
bindunbind