Package org.apache.catalina
Interface Context
-
- All Superinterfaces:
Container
- All Known Implementing Classes:
AdHocWebModule
,ContextFacade
,PwcWebModule
,StandardContext
,WebModule
public interface Context extends Container
A Context is a Container that represents a servlet context, and therefore an individual web application, in the Catalina servlet engine. It is therefore useful in almost every deployment of Catalina (even if a Connector attached to a web server (such as Apache) uses the web server's facilities to identify the appropriate Wrapper to handle this request. It also provides a convenient mechanism to use Interceptors that see every request processed by this particular web application.The parent Container attached to a Context is generally a Host, but may be some other implementation, or may be omitted if it is not necessary.
The child containers attached to a Context are generally implementations of Wrapper (representing individual servlet definitions).
- Version:
- $Revision: 1.4 $ $Date: 2007/05/05 05:31:51 $
- Author:
- Craig R. McClanahan
-
-
Field Summary
Fields Modifier and Type Field Description static String
RELOAD_EVENT
The LifecycleEvent type sent when a context is reloaded.-
Fields inherited from interface org.apache.catalina.Container
ADD_CHILD_EVENT, ADD_MAPPER_EVENT, ADD_VALVE_EVENT, REMOVE_CHILD_EVENT, REMOVE_MAPPER_EVENT, REMOVE_VALVE_EVENT
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addApplicationListener(String listener)
Adds the Listener with the given class name that is declared in the deployment descriptor to the set of Listeners configured for this application.void
addApplicationParameter(ApplicationParameter parameter)
Add a new application parameter for this application.void
addConstraint(SecurityConstraint constraint)
Add a security constraint to the set for this web application.void
addEjb(ContextEjb ejb)
Add an EJB resource reference for this web application.void
addEnvironment(ContextEnvironment environment)
Add an environment entry for this web application.void
addErrorPage(ErrorPage errorPage)
Add an error page for the specified error or Java exception.void
addFilterDef(FilterDef filterDef)
Add a filter definition to this Context.void
addFilterMap(FilterMap filterMap)
Add a filter mapping to this Context.void
addInstanceListener(String listener)
Add the classname of an InstanceListener to be added to each Wrapper appended to this Context.void
addJspMapping(String pattern)
Add the given URL pattern as a jsp-property-group.void
addLocaleEncodingMappingParameter(String locale, String encoding)
Add a Locale Encoding Mapping (see Sec 5.4 of Servlet spec 2.4)void
addLocalEjb(ContextLocalEjb ejb)
Add a local EJB resource reference for this web application.void
addMimeMapping(String extension, String mimeType)
Add a new MIME mapping, replacing any existing mapping for the specified extension.void
addParameter(String name, String value)
Add a new context initialization parameter, replacing any existing value for the specified name.void
addResource(ContextResource resource)
Add a resource reference for this web application.void
addResourceEnvRef(String name, String type)
Add a resource environment reference for this web application.void
addResourceLink(ContextResourceLink resourceLink)
Add a resource link for this web application.void
addRoleMapping(String role, String link)
Add a security role reference for this web application.void
addSecurityRole(String role)
Add a new security role for this web application.jakarta.servlet.ServletRegistration.Dynamic
addServlet(String servletName, jakarta.servlet.Servlet instance, Map<String,String> initParams)
Adds the given servlet instance with the given name to this servlet context and initializes it.jakarta.servlet.ServletRegistration.Dynamic
addServlet(String servletName, jakarta.servlet.Servlet instance, Map<String,String> initParams, String... urlPatterns)
Adds the given servlet instance with the given name and URL patterns to this servlet context, and initializes it.void
addServletMapping(String pattern, String name)
Adds the given servlet mapping to this Context, overriding any existing mapping for the specified pattern.void
addWatchedResource(String name)
Add a resource which will be watched for reloading by the host auto deployer.void
addWelcomeFile(String name)
Add a new welcome file to the set recognized by this Context.void
addWrapperLifecycle(String listener)
Add the classname of a LifecycleListener to be added to each Wrapper appended to this Context.void
addWrapperListener(String listener)
Add the classname of a ContainerListener to be added to each Wrapper appended to this Context.Wrapper
createWrapper()
Factory method to create and return a new Wrapper instance, of the Java implementation class appropriate for this Context implementation.List<ApplicationParameter>
findApplicationParameters()
Gets the (possibly empty) list of application parameters for this application.ContextEjb
findEjb(String name)
Return the EJB resource reference with the specified name, if any; otherwise, returnnull
.ContextEjb[]
findEjbs()
Return the defined EJB resource references for this application.ContextEnvironment
findEnvironment(String name)
Return the environment entry with the specified name, if any; otherwise, returnnull
.ContextEnvironment[]
findEnvironments()
Return the set of defined environment entries for this web application.ErrorPage
findErrorPage(int errorCode)
Return the error page entry for the specified HTTP error code, if any; otherwise returnnull
.ErrorPage
findErrorPage(String exceptionType)
Return the error page entry for the specified Java exception type, if any; otherwise returnnull
.FilterDef
findFilterDef(String filterName)
Return the filter definition for the specified filter name, if any; otherwise returnnull
.FilterDef[]
findFilterDefs()
Return the set of defined filters for this Context.List<FilterMap>
findFilterMaps()
Gets the (possibly empty) list of filter mappings for this Context.List<String>
findInstanceListeners()
Gets the (possibly empty) list of InstanceListener classes that will be added to newly created Wrappers automatically.ContextLocalEjb
findLocalEjb(String name)
Return the local EJB resource reference with the specified name, if any; otherwise, returnnull
.ContextLocalEjb[]
findLocalEjbs()
Return the defined local EJB resource references for this application.String
findMimeMapping(String extension)
Return the MIME type to which the specified extension is mapped, if any; otherwise returnnull
.String[]
findMimeMappings()
Return the extensions for which MIME mappings are defined.String
findParameter(String name)
Return the value for the specified context initialization parameter name, if any; otherwise returnnull
.String[]
findParameters()
Return the names of all defined context initialization parameters for this Context.ContextResource
findResource(String name)
Return the resource reference with the specified name, if any; otherwise returnnull
.String
findResourceEnvRef(String name)
Return the resource environment reference type for the specified name, if any; otherwise returnnull
.String[]
findResourceEnvRefs()
Return the set of resource environment reference names for this web application.ContextResourceLink
findResourceLink(String name)
Return the resource link with the specified name, if any; otherwise returnnull
.ContextResourceLink[]
findResourceLinks()
Return the defined resource links for this application.ContextResource[]
findResources()
Return the defined resource references for this application.String
findRoleMapping(String role)
For the given security role (as used by an application), return the corresponding role name (as defined by the underlying Realm) if there is one.String
findServletMapping(String pattern)
Return the servlet name mapped by the specified pattern (if any); otherwise returnnull
.String[]
findServletMappings()
Return the patterns of all defined servlet mappings for this Context.ErrorPage
findStatusPage(int status)
Return the context-relative URI of the error page for the specified HTTP status code, if any; otherwise returnnull
.int[]
findStatusPages()
Return the set of HTTP status codes for which error pages have been specified.boolean
findWelcomeFile(String name)
Returntrue
if the specified welcome file is defined for this Context; otherwise returnfalse
.String[]
findWelcomeFiles()
Return the set of welcome files defined for this Context.List<String>
findWrapperLifecycles()
Gets the (possibly empty) list of LifecycleListener classes that will be added to newly created Wrappers automatically.List<String>
findWrapperListeners()
Gets the (possibly empty) list of ContainerListener classes that will be added to newly created Wrappers automatically.void
fireRequestDestroyedEvent(jakarta.servlet.ServletRequest request)
Notifies all ServletRequestListener instances configured for this Context of the requestDestroyed event.void
fireRequestInitializedEvent(jakarta.servlet.ServletRequest request)
Notifies all ServletRequestListener instances configured for this Context of the requestInitialized event.String
getAdHocServletName(String path)
Returns the name of the ad-hoc servlet responsible for servicing the given path.boolean
getAllowRelativeRedirect()
Return whether this context allows sendRedirect() to redirect to a relative URL.String
getAltDDName()
Return the alternate Deployment Descriptor name.List<EventListener>
getApplicationEventListeners()
Auditor[]
getAuditors()
Get Auditors associated with this context, if any.Authenticator
getAuthenticator()
Gets the Authenticator of this Context.boolean
getAvailable()
Return the application available flag for this Context.CharsetMapper
getCharsetMapper()
Return the Locale to character set mapper for this Context.String
getConfigFile()
Return the path to a file to save this Context information.boolean
getConfigured()
Return the "correctly configured" flag for this Context.List<SecurityConstraint>
getConstraints()
Gets the (possibly empty) list of security constraints defined for this web application.boolean
getCookies()
Return the "use cookies for session ids" flag.boolean
getCrossContext()
Return the "allow crossing servlet contexts" flag.ErrorPage
getDefaultErrorPage()
Gets the default error page of this context.String
getDisplayName()
Return the display name of this web application.boolean
getDistributable()
Return the distributable flag for this web application.String
getDocBase()
Return the document root for this Context.String
getEncodedPath()
Return the URL encoded context path, using UTF-8.LoginConfig
getLoginConfig()
Return the login configuration descriptor for this web application.org.glassfish.grizzly.http.server.util.Mapper
getMapper()
Get the request dispatcher mapper.NamingResources
getNamingResources()
Return the naming resources associated with this web application.boolean
getOverride()
Return the override flag for this web application.String
getPath()
Return the context path for this web application.boolean
getPrivileged()
Return the privileged flag for this web application.String
getPublicId()
Return the public identifier of the deployment descriptor DTD that is currently being parsed.boolean
getReloadable()
Return the reloadable flag for this web application.boolean
getReuseSessionID()
Return the "reuse session IDs when creating sessions" flagjakarta.servlet.ServletContext
getServletContext()
Return the servlet context for which this Context is a facade.jakarta.servlet.SessionCookieConfig
getSessionCookieConfig()
String
getSessionCookieName()
String
getSessionParameterName()
int
getSessionTimeout()
Return the default session timeout (in minutes) for this web application.boolean
getTldNamespaceAware()
Get the server.xmlattribute's xmlNamespaceAware. boolean
getTldValidation()
Get the server.xmlattribute's webXmlValidation. List<String>
getWatchedResources()
Gets the watched resources defined for this web application.boolean
getXmlNamespaceAware()
Get the server.xmlattribute's xmlNamespaceAware. boolean
getXmlValidation()
Get the server.xmlattribute's xmlValidation. boolean
hasAdHocPaths()
Indicates whether this web module contains any ad-hoc paths.boolean
hasConstraints()
Checks whether this web application has any security constraints defined.boolean
hasSecurityRole(String role)
Checks if the given security role is defined for this application.boolean
hasWatchedResources()
Checks whether this web application has any watched resources defined.boolean
isEnableURLRewriting()
Checks whether the rewriting of URLs with the jsessionids of HTTP sessions belonging to this context is enabled or not.boolean
isJsfApplication()
Returntrue
if this context contains the JSF servlet.boolean
isSecurePagesWithPragma()
Indicates whether the Pragma and Cache-Control headers will be set to "No-cache" if proxy caching has been disabled.void
reload()
Reload this web application, if reloading is supported.void
removeApplicationParameter(String name)
Remove the application parameter with the specified name from the set for this application.void
removeConstraints()
Removes any security constraints from this web application.void
removeEjb(String name)
Remove any EJB resource reference with the specified name.void
removeEnvironment(String name)
Remove any environment entry with the specified name.void
removeErrorPages()
Removes any error page declarations from this Context.void
removeFilterDef(FilterDef filterDef)
Remove the specified filter definition from this Context, if it exists; otherwise, no action is taken.void
removeFilterMaps()
Removes any filter mappings from this Context.void
removeInstanceListener(String listener)
Remove a class name from the set of InstanceListener classes that will be added to newly created Wrappers.void
removeLocalEjb(String name)
Remove any local EJB resource reference with the specified name.void
removeMimeMapping(String extension)
Remove the MIME mapping for the specified extension, if it exists; otherwise, no action is taken.void
removeParameter(String name)
Remove the context initialization parameter with the specified name, if it exists; otherwise, no action is taken.void
removeResource(String name)
Remove any resource reference with the specified name.void
removeResourceEnvRef(String name)
Remove any resource environment reference with the specified name.void
removeResourceLink(String name)
Remove any resource link with the specified name.void
removeRoleMapping(String role)
Remove any security role reference for the specified namevoid
removeSecurityRoles()
Removes any security roles defined for this application.void
removeServletMapping(String pattern)
Remove any servlet mapping for the specified pattern, if it exists; otherwise, no action is taken.void
removeWatchedResources()
Clears any watched resources defined for this web application.void
removeWelcomeFiles()
void
removeWrapperLifecycles()
Removes any Wrapper lifecycle listeners from this Contextvoid
removeWrapperListeners()
Removes any Wrapper listeners from this Contextvoid
setAllowRelativeRedirect(boolean allowRelativeURLs)
Set whether this context allows sendRedirect() to redirect to a relative URL.void
setAltDDName(String altDDName)
Set an alternate Deployment Descriptor name.void
setAuditors(Auditor[] auditor)
Set the Auditors associated with this context.void
setAvailable(boolean available)
Set the application available flag for this Context.void
setCharsetMapper(CharsetMapper mapper)
Set the Locale to character set mapper for this Context.void
setConfigFile(String configFile)
Set the path to a file to save this Context information.void
setConfigured(boolean configured)
Set the "correctly configured" flag for this Context.void
setCookies(boolean cookies)
Set the "use cookies for session ids" flag.void
setCrossContext(boolean crossContext)
Set the "allow crossing servlet contexts" flag.void
setDisplayName(String displayName)
Set the display name of this web application.void
setDistributable(boolean distributable)
Set the distributable flag for this web application.void
setDocBase(String docBase)
Set the document root for this Context.void
setEnableURLRewriting(boolean enableURLRewriting)
Enables or disables the rewriting of URLs with the jsessionids of HTTP sessions belonging to this context.void
setLoginConfig(LoginConfig config)
Set the login configuration descriptor for this web application.void
setNamingResources(NamingResources namingResources)
Set the naming resources for this web application.void
setOverride(boolean override)
Set the override flag for this web application.void
setPath(String path)
Set the context path for this web application.void
setPrivileged(boolean privileged)
Set the privileged flag for this web application.void
setPublicId(String publicId)
Set the public identifier of the deployment descriptor DTD that is currently being parsed.void
setReloadable(boolean reloadable)
Set the reloadable flag for this web application.void
setReuseSessionID(boolean reuse)
Set the "reuse session IDs when creating sessions" flagvoid
setSecurePagesWithPragma(boolean securePagesWithPragma)
Sets the securePagesWithPragma property of this Context.void
setSessionTimeout(int timeout)
Set the default session timeout (in minutes) for this web application.void
setTldNamespaceAware(boolean tldNamespaceAware)
Set the namespace aware feature of the XML parser used when parsing xml instances.void
setTldValidation(boolean tldValidation)
Set the validation feature of the XML parser used when parsing tlds files.void
setXmlNamespaceAware(boolean xmlNamespaceAware)
Set the namespace aware feature of the XML parser used when parsing xml instances.void
setXmlValidation(boolean xmlValidation)
Set the validation feature of the XML parser used when parsing xml instances.-
Methods inherited from interface org.apache.catalina.Container
addChild, addContainerListener, addPropertyChangeListener, backgroundProcess, findChild, findChildren, findContainerListeners, fireContainerEvent, getBackgroundProcessorDelay, getInfo, getLoader, getLogger, getManager, getMappingObject, getName, getParent, getParentClassLoader, getPipeline, getRealm, getResources, hasCustomPipeline, invoke, isCheckIfRequestIsSecure, removeChild, removeContainerListener, removePropertyChangeListener, setBackgroundProcessorDelay, setCheckIfRequestIsSecure, setLoader, setLogger, setManager, setName, setParent, setParentClassLoader, setRealm, setResources
-
-
-
-
Field Detail
-
RELOAD_EVENT
static final String RELOAD_EVENT
The LifecycleEvent type sent when a context is reloaded.- See Also:
- Constant Field Values
-
-
Method Detail
-
getApplicationEventListeners
List<EventListener> getApplicationEventListeners()
- Returns:
- the list of initialized application event listeners of this application, in the order in which they have been specified in the deployment descriptor
-
getAvailable
boolean getAvailable()
Return the application available flag for this Context.
-
setAvailable
void setAvailable(boolean available)
Set the application available flag for this Context.- Parameters:
available
- The new application available flag
-
getCharsetMapper
CharsetMapper getCharsetMapper()
Return the Locale to character set mapper for this Context.
-
setCharsetMapper
void setCharsetMapper(CharsetMapper mapper)
Set the Locale to character set mapper for this Context.- Parameters:
mapper
- The new mapper
-
getConfigFile
String getConfigFile()
Return the path to a file to save this Context information.
-
setConfigFile
void setConfigFile(String configFile)
Set the path to a file to save this Context information.- Parameters:
configFile
- The path to a file to save this Context information.
-
getConfigured
boolean getConfigured()
Return the "correctly configured" flag for this Context.
-
setConfigured
void setConfigured(boolean configured)
Set the "correctly configured" flag for this Context. This can be set to false by startup listeners that detect a fatal configuration error to avoid the application from being made available.- Parameters:
configured
- The new correctly configured flag
-
getCookies
boolean getCookies()
Return the "use cookies for session ids" flag.
-
setCookies
void setCookies(boolean cookies)
Set the "use cookies for session ids" flag.- Parameters:
cookies
- The new flag
-
getSessionCookieName
String getSessionCookieName()
- Returns:
- the name that will be assigned to any session tracking cookies created on behalf of this context
-
getSessionCookieConfig
jakarta.servlet.SessionCookieConfig getSessionCookieConfig()
- Returns:
- the session tracking cookie configuration of this ServletContext.
-
getSessionParameterName
String getSessionParameterName()
- Returns:
- the name that will be assigned to any session tracking parameter created on behalf of this context
-
isEnableURLRewriting
boolean isEnableURLRewriting()
Checks whether the rewriting of URLs with the jsessionids of HTTP sessions belonging to this context is enabled or not.- Returns:
- true if the rewriting of URLs with the jsessionids of HTTP sessions belonging to this context is enabled, false otherwise
-
setEnableURLRewriting
void setEnableURLRewriting(boolean enableURLRewriting)
Enables or disables the rewriting of URLs with the jsessionids of HTTP sessions belonging to this context.- Parameters:
enableURLRewriting
- true if the rewriting of URLs with the jsessionids of HTTP sessions belonging to this context should be enabled, false otherwise
-
getCrossContext
boolean getCrossContext()
Return the "allow crossing servlet contexts" flag.
-
getAltDDName
String getAltDDName()
Return the alternate Deployment Descriptor name.
-
setAltDDName
void setAltDDName(String altDDName)
Set an alternate Deployment Descriptor name.
-
setCrossContext
void setCrossContext(boolean crossContext)
Set the "allow crossing servlet contexts" flag.- Parameters:
crossContext
- The new cross contexts flag
-
getDisplayName
String getDisplayName()
Return the display name of this web application.
-
setDisplayName
void setDisplayName(String displayName)
Set the display name of this web application.- Parameters:
displayName
- The new display name
-
getDistributable
boolean getDistributable()
Return the distributable flag for this web application.
-
setDistributable
void setDistributable(boolean distributable)
Set the distributable flag for this web application.- Parameters:
distributable
- The new distributable flag
-
getDocBase
String getDocBase()
Return the document root for this Context. This can be an absolute pathname, a relative pathname, or a URL.
-
setDocBase
void setDocBase(String docBase)
Set the document root for this Context. This can be an absolute pathname, a relative pathname, or a URL.- Parameters:
docBase
- The new document root
-
getEncodedPath
String getEncodedPath()
Return the URL encoded context path, using UTF-8.
-
getLoginConfig
LoginConfig getLoginConfig()
Return the login configuration descriptor for this web application.
-
setLoginConfig
void setLoginConfig(LoginConfig config)
Set the login configuration descriptor for this web application.- Parameters:
config
- The new login configuration
-
getMapper
org.glassfish.grizzly.http.server.util.Mapper getMapper()
Get the request dispatcher mapper.
-
getNamingResources
NamingResources getNamingResources()
Return the naming resources associated with this web application.
-
setNamingResources
void setNamingResources(NamingResources namingResources)
Set the naming resources for this web application.- Parameters:
namingResources
- The new naming resources
-
getPath
String getPath()
Return the context path for this web application.
-
setPath
void setPath(String path)
Set the context path for this web application.- Parameters:
path
- The new context path
-
getPublicId
String getPublicId()
Return the public identifier of the deployment descriptor DTD that is currently being parsed.
-
setPublicId
void setPublicId(String publicId)
Set the public identifier of the deployment descriptor DTD that is currently being parsed.- Parameters:
publicId
- The public identifier
-
getReloadable
boolean getReloadable()
Return the reloadable flag for this web application.
-
setReloadable
void setReloadable(boolean reloadable)
Set the reloadable flag for this web application.- Parameters:
reloadable
- The new reloadable flag
-
getOverride
boolean getOverride()
Return the override flag for this web application.
-
setOverride
void setOverride(boolean override)
Set the override flag for this web application.- Parameters:
override
- The new override flag
-
getPrivileged
boolean getPrivileged()
Return the privileged flag for this web application.
-
setPrivileged
void setPrivileged(boolean privileged)
Set the privileged flag for this web application.- Parameters:
privileged
- The new privileged flag
-
getServletContext
jakarta.servlet.ServletContext getServletContext()
Return the servlet context for which this Context is a facade.
-
getSessionTimeout
int getSessionTimeout()
Return the default session timeout (in minutes) for this web application.
-
setSessionTimeout
void setSessionTimeout(int timeout)
Set the default session timeout (in minutes) for this web application.- Parameters:
timeout
- The new default session timeout
-
getAuditors
Auditor[] getAuditors()
Get Auditors associated with this context, if any.- Returns:
- array of Auditor objects, or null
-
setAuditors
void setAuditors(Auditor[] auditor)
Set the Auditors associated with this context.- Parameters:
auditor
- array of Auditor objects
-
addApplicationListener
void addApplicationListener(String listener)
Adds the Listener with the given class name that is declared in the deployment descriptor to the set of Listeners configured for this application.- Parameters:
listener
- the fully qualified class name of the Listener
-
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.
-
addEjb
void addEjb(ContextEjb ejb)
Add an EJB resource reference for this web application.- Parameters:
ejb
- New EJB resource reference
-
addEnvironment
void addEnvironment(ContextEnvironment environment)
Add an environment entry for this web application.- Parameters:
environment
- New environment entry
-
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
-
addInstanceListener
void addInstanceListener(String listener)
Add the classname of an InstanceListener to be added to each Wrapper appended to this Context.- Parameters:
listener
- Java class name of an InstanceListener class
-
addJspMapping
void addJspMapping(String pattern)
Add the given URL pattern as a jsp-property-group. This maps resources that match the given pattern so they will be passed to the JSP container. Though there are other elements in the property group, we only care about the URL pattern here. The JSP container will parse the rest.- Parameters:
pattern
- URL pattern to be mapped
-
addLocaleEncodingMappingParameter
void addLocaleEncodingMappingParameter(String locale, String encoding)
Add a Locale Encoding Mapping (see Sec 5.4 of Servlet spec 2.4)- Parameters:
locale
- locale to map an encoding forencoding
- encoding to be used for a give locale
-
addLocalEjb
void addLocalEjb(ContextLocalEjb ejb)
Add a local EJB resource reference for this web application.- Parameters:
ejb
- New local EJB resource reference
-
addMimeMapping
void addMimeMapping(String extension, String mimeType)
Add a new MIME mapping, replacing any existing mapping for the specified extension.- Parameters:
extension
- Filename extension being mappedmimeType
- Corresponding MIME type
-
addParameter
void addParameter(String name, String value)
Add a new context initialization parameter, replacing any existing value for the specified name.- Parameters:
name
- Name of the new parametervalue
- Value of the new parameter
-
addResource
void addResource(ContextResource resource)
Add a resource reference for this web application.- Parameters:
resource
- New resource reference
-
addResourceEnvRef
void addResourceEnvRef(String name, String type)
Add a resource environment reference for this web application.- Parameters:
name
- The resource environment reference nametype
- The resource environment reference type
-
addResourceLink
void addResourceLink(ContextResourceLink resourceLink)
Add a resource link for this web application.- Parameters:
resourceLink
- New resource link
-
addRoleMapping
void addRoleMapping(String role, 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(String role)
Add a new security role for this web application.- Parameters:
role
- New security role
-
addServletMapping
void addServletMapping(String pattern, String name)
Adds the given servlet mapping to this Context, overriding any existing mapping for the specified pattern.- Parameters:
pattern
- the URL pattern to be mappedname
- the name of the Servlet to which to map
-
addWatchedResource
void addWatchedResource(String name)
Add a resource which will be watched for reloading by the host auto deployer. Note: this will not be used in embedded mode.- Parameters:
name
- Path to the resource, relative to docBase
-
addWelcomeFile
void addWelcomeFile(String name)
Add a new welcome file to the set recognized by this Context.- Parameters:
name
- New welcome file name
-
addWrapperLifecycle
void addWrapperLifecycle(String listener)
Add the classname of a LifecycleListener to be added to each Wrapper appended to this Context.- Parameters:
listener
- Java class name of a LifecycleListener class
-
addWrapperListener
void addWrapperListener(String listener)
Add the classname of a ContainerListener to be added to each Wrapper appended to this Context.- Parameters:
listener
- Java class name of a ContainerListener class
-
createWrapper
Wrapper createWrapper()
Factory method to create and return a new Wrapper instance, of the Java implementation class appropriate for this Context implementation. The constructor of the instantiated Wrapper will have been called, but no properties will have been set.
-
addServlet
jakarta.servlet.ServletRegistration.Dynamic addServlet(String servletName, jakarta.servlet.Servlet instance, Map<String,String> initParams) throws jakarta.servlet.ServletException
Adds the given servlet instance with the given name to this servlet context and initializes it.In order to add any URL patterns that will be mapped to the given servlet, addServletMappings must be used. If this context has already been started, the URL patterns must be passed to addServlet instead.
- Parameters:
servletName
- the servlet nameinstance
- the servlet instanceinitParams
- Map containing the initialization parameters for the servlet- Returns:
- the ServletRegistration through which the servlet may be further configured
- Throws:
jakarta.servlet.ServletException
- if the servlet fails to be initialized
-
addServlet
jakarta.servlet.ServletRegistration.Dynamic addServlet(String servletName, jakarta.servlet.Servlet instance, Map<String,String> initParams, String... urlPatterns) throws jakarta.servlet.ServletException
Adds the given servlet instance with the given name and URL patterns to this servlet context, and initializes it.- Parameters:
servletName
- the servlet nameinstance
- the servlet instanceinitParams
- Map containing the initialization parameters for the servleturlPatterns
- the URL patterns that will be mapped to the servlet- Returns:
- the ServletRegistration through which the servlet may be further configured
- Throws:
jakarta.servlet.ServletException
- if the servlet fails to be initialized
-
findApplicationParameters
List<ApplicationParameter> findApplicationParameters()
Gets the (possibly empty) list of application parameters for this application.
-
getConstraints
List<SecurityConstraint> getConstraints()
Gets the (possibly empty) list of security constraints defined for this web application.
-
hasConstraints
boolean hasConstraints()
Checks whether this web application has any security constraints defined.
-
removeConstraints
void removeConstraints()
Removes any security constraints from this web application.
-
findEjb
ContextEjb findEjb(String name)
Return the EJB resource reference with the specified name, if any; otherwise, returnnull
.- Parameters:
name
- Name of the desired EJB resource reference
-
findEjbs
ContextEjb[] findEjbs()
Return the defined EJB resource references for this application. If there are none, a zero-length array is returned.
-
findEnvironment
ContextEnvironment findEnvironment(String name)
Return the environment entry with the specified name, if any; otherwise, returnnull
.- Parameters:
name
- Name of the desired environment entry
-
findEnvironments
ContextEnvironment[] findEnvironments()
Return the set of defined environment entries for this web application. If none have been defined, a zero-length array is returned.
-
findErrorPage
ErrorPage findErrorPage(int errorCode)
Return the error page entry for the specified HTTP error code, if any; otherwise returnnull
.- Parameters:
errorCode
- Error code to look up
-
findErrorPage
ErrorPage findErrorPage(String exceptionType)
Return the error page entry for the specified Java exception type, if any; otherwise returnnull
.- Parameters:
exceptionType
- Exception type to look up
-
getDefaultErrorPage
ErrorPage getDefaultErrorPage()
Gets the default error page of this context.A default error page is an error page that was declared without any exception-type and error-code.
- Returns:
- the default error page of this context, or null if this context does not have any default error page
-
findFilterDef
FilterDef findFilterDef(String filterName)
Return the filter definition for the specified filter name, if any; otherwise returnnull
.- Parameters:
filterName
- Filter name to look up
-
findFilterDefs
FilterDef[] findFilterDefs()
Return the set of defined filters for this Context.
-
findFilterMaps
List<FilterMap> findFilterMaps()
Gets the (possibly empty) list of filter mappings for this Context.
-
findInstanceListeners
List<String> findInstanceListeners()
Gets the (possibly empty) list of InstanceListener classes that will be added to newly created Wrappers automatically.
-
findLocalEjb
ContextLocalEjb findLocalEjb(String name)
Return the local EJB resource reference with the specified name, if any; otherwise, returnnull
.- Parameters:
name
- Name of the desired EJB resource reference
-
findLocalEjbs
ContextLocalEjb[] findLocalEjbs()
Return the defined local EJB resource references for this application. If there are none, a zero-length array is returned.
-
findMimeMapping
String findMimeMapping(String extension)
Return the MIME type to which the specified extension is mapped, if any; otherwise returnnull
.- Parameters:
extension
- Extension to map to a MIME type
-
findMimeMappings
String[] findMimeMappings()
Return the extensions for which MIME mappings are defined. If there are none, a zero-length array is returned.
-
findParameter
String findParameter(String name)
Return the value for the specified context initialization parameter name, if any; otherwise returnnull
.- Parameters:
name
- Name of the parameter to return
-
findParameters
String[] findParameters()
Return the names of all defined context initialization parameters for this Context. If no parameters are defined, a zero-length array is returned.
-
findResource
ContextResource findResource(String name)
Return the resource reference with the specified name, if any; otherwise returnnull
.- Parameters:
name
- Name of the desired resource reference
-
findResourceEnvRef
String findResourceEnvRef(String name)
Return the resource environment reference type for the specified name, if any; otherwise returnnull
.- Parameters:
name
- Name of the desired resource environment reference
-
findResourceEnvRefs
String[] findResourceEnvRefs()
Return the set of resource environment reference names for this web application. If none have been specified, a zero-length array is returned.
-
findResourceLink
ContextResourceLink findResourceLink(String name)
Return the resource link with the specified name, if any; otherwise returnnull
.- Parameters:
name
- Name of the desired resource link
-
findResourceLinks
ContextResourceLink[] findResourceLinks()
Return the defined resource links for this application. If none have been defined, a zero-length array is returned.
-
findResources
ContextResource[] findResources()
Return the defined resource references for this application. If none have been defined, a zero-length array is returned.
-
findRoleMapping
String findRoleMapping(String role)
For the given security role (as used by an application), return the corresponding role name (as defined by the underlying Realm) if there is one. Otherwise, return the specified role unchanged.- Parameters:
role
- Security role to map
-
hasSecurityRole
boolean hasSecurityRole(String role)
Checks if the given security role is defined for this application.- Parameters:
role
- Security role to check for- Returns:
- true if the specified security role is defined for this application, false otherwise
-
removeSecurityRoles
void removeSecurityRoles()
Removes any security roles defined for this application.
-
findServletMapping
String findServletMapping(String pattern)
Return the servlet name mapped by the specified pattern (if any); otherwise returnnull
.- Parameters:
pattern
- Pattern for which a mapping is requested
-
findServletMappings
String[] findServletMappings()
Return the patterns of all defined servlet mappings for this Context. If no mappings are defined, a zero-length array is returned.
-
findStatusPage
ErrorPage findStatusPage(int status)
Return the context-relative URI of the error page for the specified HTTP status code, if any; otherwise returnnull
.- Parameters:
status
- HTTP status code to look up
-
findStatusPages
int[] findStatusPages()
Return the set of HTTP status codes for which error pages have been specified. If none are specified, a zero-length array is returned.
-
getWatchedResources
List<String> getWatchedResources()
Gets the watched resources defined for this web application.
-
findWelcomeFile
boolean findWelcomeFile(String name)
Returntrue
if the specified welcome file is defined for this Context; otherwise returnfalse
.- Parameters:
name
- Welcome file to verify
-
findWelcomeFiles
String[] findWelcomeFiles()
Return the set of welcome files defined for this Context. If none are defined, a zero-length array is returned.
-
findWrapperLifecycles
List<String> findWrapperLifecycles()
Gets the (possibly empty) list of LifecycleListener classes that will be added to newly created Wrappers automatically.
-
findWrapperListeners
List<String> findWrapperListeners()
Gets the (possibly empty) list of ContainerListener classes that will be added to newly created Wrappers automatically.
-
reload
void reload()
Reload this web application, if reloading is supported.- Throws:
IllegalStateException
- if thereloadable
property is set tofalse
.
-
removeApplicationParameter
void removeApplicationParameter(String name)
Remove the application parameter with the specified name from the set for this application.- Parameters:
name
- Name of the application parameter to remove
-
removeEjb
void removeEjb(String name)
Remove any EJB resource reference with the specified name.- Parameters:
name
- Name of the EJB resource reference to remove
-
removeEnvironment
void removeEnvironment(String name)
Remove any environment entry with the specified name.- Parameters:
name
- Name of the environment entry to remove
-
removeErrorPages
void removeErrorPages()
Removes any error page declarations from this Context.
-
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
-
removeFilterMaps
void removeFilterMaps()
Removes any filter mappings from this Context.
-
removeInstanceListener
void removeInstanceListener(String listener)
Remove a class name from the set of InstanceListener classes that will be added to newly created Wrappers.- Parameters:
listener
- Class name of an InstanceListener class to be removed
-
removeLocalEjb
void removeLocalEjb(String name)
Remove any local EJB resource reference with the specified name.- Parameters:
name
- Name of the EJB resource reference to remove
-
removeMimeMapping
void removeMimeMapping(String extension)
Remove the MIME mapping for the specified extension, if it exists; otherwise, no action is taken.- Parameters:
extension
- Extension to remove the mapping for
-
removeParameter
void removeParameter(String name)
Remove the context initialization parameter with the specified name, if it exists; otherwise, no action is taken.- Parameters:
name
- Name of the parameter to remove
-
removeResource
void removeResource(String name)
Remove any resource reference with the specified name.- Parameters:
name
- Name of the resource reference to remove
-
removeResourceEnvRef
void removeResourceEnvRef(String name)
Remove any resource environment reference with the specified name.- Parameters:
name
- Name of the resource environment reference to remove
-
removeResourceLink
void removeResourceLink(String name)
Remove any resource link with the specified name.- Parameters:
name
- Name of the resource link to remove
-
removeRoleMapping
void removeRoleMapping(String role)
Remove any security role reference for the specified name- Parameters:
role
- Security role (as used in the application) to remove
-
removeServletMapping
void removeServletMapping(String pattern)
Remove any servlet mapping for the specified pattern, if it exists; otherwise, no action is taken.- Parameters:
pattern
- URL pattern of the mapping to remove
-
hasWatchedResources
boolean hasWatchedResources()
Checks whether this web application has any watched resources defined.
-
removeWatchedResources
void removeWatchedResources()
Clears any watched resources defined for this web application.
-
removeWrapperLifecycles
void removeWrapperLifecycles()
Removes any Wrapper lifecycle listeners from this Context
-
removeWrapperListeners
void removeWrapperListeners()
Removes any Wrapper listeners from this Context
-
removeWelcomeFiles
void removeWelcomeFiles()
-
getReuseSessionID
boolean getReuseSessionID()
Return the "reuse session IDs when creating sessions" flag
-
setReuseSessionID
void setReuseSessionID(boolean reuse)
Set the "reuse session IDs when creating sessions" flag- Parameters:
reuse
- The new value for the flag
-
getAllowRelativeRedirect
boolean getAllowRelativeRedirect()
Return whether this context allows sendRedirect() to redirect to a relative URL. The default value for this property is 'false'.
-
setAllowRelativeRedirect
void setAllowRelativeRedirect(boolean allowRelativeURLs)
Set whether this context allows sendRedirect() to redirect to a relative URL.- Parameters:
allowRelativeURLs
- The new value for this property. The default value for this flag is 'false'.
-
getXmlNamespaceAware
boolean getXmlNamespaceAware()
Get the server.xmlattribute's xmlNamespaceAware. - Returns:
- true if namespace awareness is enabled.
-
getXmlValidation
boolean getXmlValidation()
Get the server.xmlattribute's xmlValidation. - Returns:
- true if validation is enabled.
-
setXmlValidation
void setXmlValidation(boolean xmlValidation)
Set the validation feature of the XML parser used when parsing xml instances.- Parameters:
xmlValidation
- true to enable xml instance validation
-
setXmlNamespaceAware
void setXmlNamespaceAware(boolean xmlNamespaceAware)
Set the namespace aware feature of the XML parser used when parsing xml instances.- Parameters:
xmlNamespaceAware
- true to enable namespace awareness
-
setTldValidation
void setTldValidation(boolean tldValidation)
Set the validation feature of the XML parser used when parsing tlds files.- Parameters:
tldValidation
- true to enable xml instance validation
-
getTldValidation
boolean getTldValidation()
Get the server.xmlattribute's webXmlValidation. - Returns:
- true if validation is enabled.
-
getTldNamespaceAware
boolean getTldNamespaceAware()
Get the server.xmlattribute's xmlNamespaceAware. - Returns:
- true if namespace awareness is enabled.
-
setTldNamespaceAware
void setTldNamespaceAware(boolean tldNamespaceAware)
Set the namespace aware feature of the XML parser used when parsing xml instances.- Parameters:
tldNamespaceAware
- true to enable namespace awareness
-
isJsfApplication
boolean isJsfApplication()
Returntrue
if this context contains the JSF servlet.
-
hasAdHocPaths
boolean hasAdHocPaths()
Indicates whether this web module contains any ad-hoc paths. An ad-hoc path is a servlet path that is mapped to a servlet not declared in the web module's deployment descriptor. A web module all of whose mappings are for ad-hoc paths is called an ad-hoc web module.- Returns:
- true if this web module contains any ad-hoc paths, false otherwise
-
getAdHocServletName
String getAdHocServletName(String path)
Returns the name of the ad-hoc servlet responsible for servicing the given path.- Parameters:
path
- The path to service- Returns:
- The name of the ad-hoc servlet responsible for servicing the given path, or null if the given path is not an ad-hoc path
-
isSecurePagesWithPragma
boolean isSecurePagesWithPragma()
Indicates whether the Pragma and Cache-Control headers will be set to "No-cache" if proxy caching has been disabled.- Returns:
- true if Pragma and Cache-Control headers will be set to "No-cache" if proxy caching has been disabled; false otherwise.
-
setSecurePagesWithPragma
void setSecurePagesWithPragma(boolean securePagesWithPragma)
Sets the securePagesWithPragma property of this Context. Setting this property to true will result in Pragma and Cache-Control headers with a value of "No-cache" if proxy caching has been disabled. Setting this property to false will not add any Pragma header, but will set the Cache-Control header to "private".- Parameters:
securePagesWithPragma
- true if Pragma and Cache-Control headers are to be set to "No-cache" if proxy caching has been disabled, false otherwise
-
getAuthenticator
Authenticator getAuthenticator()
Gets the Authenticator of this Context.- Returns:
- the Authenticator of this Context
-
fireRequestInitializedEvent
void fireRequestInitializedEvent(jakarta.servlet.ServletRequest request)
Notifies all ServletRequestListener instances configured for this Context of the requestInitialized event.- Parameters:
request
-
-
fireRequestDestroyedEvent
void fireRequestDestroyedEvent(jakarta.servlet.ServletRequest request)
Notifies all ServletRequestListener instances configured for this Context of the requestDestroyed event.- Parameters:
request
-
-
-