Top Description Inners Fields Constructors Methods
org.apache.catalina.core

public Class ApplicationContext

extends Object
implements ServletContext
Class Inheritance
All Implemented Interfaces
jakarta.servlet.ServletContext
Imports
java.io.InputStream, java.lang.reflect.InvocationTargetException, java.net.MalformedURLException, .URL, java.nio.charset.StandardCharsets, java.util.ArrayList, .Collections, .EnumSet, .Enumeration, .EventListener, .HashMap, .HashSet, .List, .Map, .Set, java.util.concurrent.ConcurrentHashMap, javax.naming.NamingException, jakarta.servlet.Filter, .FilterRegistration, .RequestDispatcher, .Servlet, .ServletContext, .ServletContextAttributeEvent, .ServletContextAttributeListener, .ServletContextListener, .ServletException, .ServletRegistration, .ServletRegistration.Dynamic, .ServletRequestAttributeListener, .ServletRequestListener, .ServletSecurityElement, .SessionCookieConfig, .SessionTrackingMode, jakarta.servlet.annotation.ServletSecurity, jakarta.servlet.descriptor.JspConfigDescriptor, jakarta.servlet.http.HttpServletMapping, .HttpSessionAttributeListener, .HttpSessionIdListener, .HttpSessionListener, org.apache.catalina.Container, .Context, .Engine, .Globals, .LifecycleState, .Service, .WebResourceRoot, .Wrapper, org.apache.catalina.connector.Connector, org.apache.catalina.mapper.MappingData, org.apache.catalina.util.Introspection, .ServerInfo, .URLEncoder, org.apache.tomcat.util.ExceptionUtils, org.apache.tomcat.util.buf.CharChunk, .MessageBytes, .UDecoder, org.apache.tomcat.util.descriptor.web.FilterDef, org.apache.tomcat.util.http.RequestUtil, org.apache.tomcat.util.res.StringManager

Standard implementation of ServletContext that represents a web application's execution environment. An instance of this class is associated with each instance of StandardContext.
Authors
Craig R. McClanahan, Remy Maucherat

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
ApplicationContext.DispatchData

Internal class used as thread-local storage when doing path mapping during dispatch.

Field Summary

Modifier and TypeField and Description
protected Map<String, Object>
attributes

The context attributes for this context.

private final StandardContext
context

The Context instance with which we are associated.

private Set<SessionTrackingMode>
private final ThreadLocal<ApplicationContext.DispatchData>
dispatchData

Thread local data used during request dispatch.

private final ServletContext
facade

The facade around this object.

private boolean
newServletContextListenerAllowed

Flag that indicates if a new ServletContextListener may be added to the application.

private final Map<String, String>
parameters

The merged context initialization parameters for this Context.

private final Map<String, String>
readOnlyAttributes

List of read only attributes for this context.

private final Service
service

The Service instance with which we are associated.

private SessionCookieConfig
sessionCookieConfig

Session Cookie config

private Set<SessionTrackingMode>
sessionTrackingModes

Session tracking modes

private static final StringManager
sm

The string manager for this package.

private Set<SessionTrackingMode>

Constructor Summary

AccessConstructor and Description
public
ApplicationContext(StandardContext
The associated Context instance
context
)

Construct a new instance of this class, associated with the specified Context instance.

Method Summary

Modifier and TypeMethod and Description
public FilterRegistration.Dynamic
addFilter(String
Name of filter to add
filterName
,
String
Name of filter class
className
)

Implements jakarta.servlet.ServletContext.addFilter.

Add filter to context.

public FilterRegistration.Dynamic
addFilter(String
Name of filter to add
filterName
,
Filter
Filter to add
filter
)

Implements jakarta.servlet.ServletContext.addFilter.

Add filter to context.

public FilterRegistration.Dynamic
addFilter(String
Name of filter to add
filterName
,
Class<? extends Filter>
Class of filter to add
filterClass
)

Implements jakarta.servlet.ServletContext.addFilter.

Add filter to context.

private FilterRegistration.Dynamic
addFilter(String filterName, String filterClass, Filter filter)

public ServletRegistration.Dynamic
addJspFile(String
The servlet name under which this JSP file should be registered
jspName
,
String
The path, relative to the web application root, for the JSP file to be used for this servlet
jspFile
)

Implements jakarta.servlet.ServletContext.addJspFile.

Add a JSP to the context.

public void
addListener(Class<? extends EventListener>
TODO
listenerClass
)

Implements jakarta.servlet.ServletContext.addListener, jakarta.servlet.ServletContext.addListener.

TODO SERVLET3 - Add comments

public void
public <T extends EventListener> void
addListener(T
TODO
t
)

Implements jakarta.servlet.ServletContext.addListener.

TODO SERVLET3 - Add comments

public ServletRegistration.Dynamic
addServlet(String
The name of the servlet to register
servletName
,
String
The implementation class for the servlet
className
)

Implements jakarta.servlet.ServletContext.addServlet.

Register a servlet implementation for use in this ServletContext.

public ServletRegistration.Dynamic
addServlet(String
The name of the servlet to register
servletName
,
Servlet
The Servlet instance to register
servlet
)

Implements jakarta.servlet.ServletContext.addServlet.

Register a servlet instance for use in this ServletContext.

public ServletRegistration.Dynamic
addServlet(String
Name of servlet to add
servletName
,
Class<? extends Servlet>
Class of servlet to add
servletClass
)

Implements jakarta.servlet.ServletContext.addServlet.

Add servlet to the context.

private ServletRegistration.Dynamic
addServlet(String servletName, String servletClass, Servlet servlet, Map<String, String> initParams)

private void
checkState(String messageKey)

protected void
clearAttributes()

Clear all application-created attributes.

public <T extends Filter> T
createFilter(Class<T>
The the class for which an instance should be created
c
)

Implements jakarta.servlet.ServletContext.createFilter.

Create a Filter instance using the given class.

public <T extends EventListener> T
createListener(Class<T>
TODO
c
)

Implements jakarta.servlet.ServletContext.createListener.

TODO SERVLET3 - Add comments

public <T extends Servlet> T
createServlet(Class<T>
The the class for which an instance should be created
c
)

Implements jakarta.servlet.ServletContext.createServlet.

Create an Servlet instance using the given class.

public void
declareRoles(String...
The roles to add
roleNames
)

Implements jakarta.servlet.ServletContext.declareRoles.

Add to the declared roles for this ServletContext.

public Object
getAttribute(String
a String specifying the name of the attribute
name
)

Implements jakarta.servlet.ServletContext.getAttribute.

Returns the servlet container attribute with the given name, or null if there is no attribute by that name.

public Enumeration<String>
getAttributeNames()

Implements jakarta.servlet.ServletContext.getAttributeNames.

Returns an Enumeration containing the attribute names available within this servlet context.

public ClassLoader
getClassLoader()

Implements jakarta.servlet.ServletContext.getClassLoader.

Get the web application class loader associated with this ServletContext.

public ServletContext
getContext(String
a String specifying the context path of another web application in the container.
uri
)

Implements jakarta.servlet.ServletContext.getContext.

Returns a ServletContext object that corresponds to a specified URL on the server.

protected StandardContext
public String
getContextPath()

Implements jakarta.servlet.ServletContext.getContextPath.

Return the main path associated with this context.

public Set<SessionTrackingMode>
getDefaultSessionTrackingModes()

Implements jakarta.servlet.ServletContext.getDefaultSessionTrackingModes.

Obtains the default session tracking modes for this web application.

public int
getEffectiveMajorVersion()

Implements jakarta.servlet.ServletContext.getEffectiveMajorVersion.

Obtain the major version of the servlet specification for which this web application is implemented.

public int
getEffectiveMinorVersion()

Implements jakarta.servlet.ServletContext.getEffectiveMinorVersion.

Obtain the minor version of the servlet specification for which this web application is implemented.

public Set<SessionTrackingMode>
getEffectiveSessionTrackingModes()

Implements jakarta.servlet.ServletContext.getEffectiveSessionTrackingModes.

Obtains the currently enabled session tracking modes for this web application.

protected ServletContext

Returns:

the facade associated with this ApplicationContext.
getFacade
()

public FilterRegistration
getFilterRegistration(String
TODO
filterName
)

Implements jakarta.servlet.ServletContext.getFilterRegistration.

TODO SERVLET3 - Add comments

public Map<String, ? extends FilterRegistration>
public String
getInitParameter(final String
a String containing the name of the parameter whose value is requested
name
)

Implements jakarta.servlet.ServletContext.getInitParameter.

Returns a String containing the value of the named context-wide initialization parameter, or null if the parameter does not exist.

public Enumeration<String>
getInitParameterNames()

Implements jakarta.servlet.ServletContext.getInitParameterNames.

Returns the names of the context's initialization parameters as an Enumeration of String objects, or an empty Enumeration if the context has no initialization parameters.

public JspConfigDescriptor
public int
getMajorVersion()

Implements jakarta.servlet.ServletContext.getMajorVersion.

Returns the major version of the Java Servlet API that this servlet container supports.

public String
getMimeType(String
Filename for which to identify a MIME type
file
)

Implements jakarta.servlet.ServletContext.getMimeType.

Return the MIME type of the specified file, or null if the MIME type cannot be determined.

public int
getMinorVersion()

Implements jakarta.servlet.ServletContext.getMinorVersion.

Returns the minor version of the Servlet API that this servlet container supports.

public RequestDispatcher
getNamedDispatcher(String
Name of the servlet for which a dispatcher is requested
name
)

Implements jakarta.servlet.ServletContext.getNamedDispatcher.

Return a RequestDispatcher object that acts as a wrapper for the named servlet.

public String
getRealPath(String
a String specifying a virtual path
path
)

Implements jakarta.servlet.ServletContext.getRealPath.

Returns a String containing the real path for a given virtual path.

public String
getRequestCharacterEncoding()

Implements jakarta.servlet.ServletContext.getRequestCharacterEncoding.

Get the default character encoding for reading request bodies.

public RequestDispatcher
getRequestDispatcher(final String
a String specifying the pathname to the resource
path
)

Implements jakarta.servlet.ServletContext.getRequestDispatcher.

Returns a RequestDispatcher object that acts as a wrapper for the resource located at the given path.

public URL
getResource(String
a String specifying the path to the resource
path
)

Implements jakarta.servlet.ServletContext.getResource.

Returns a URL to the resource that is mapped to a specified path.

public InputStream
getResourceAsStream(String
a String specifying the path to the resource
path
)

Implements jakarta.servlet.ServletContext.getResourceAsStream.

Returns the resource located at the named path as an InputStream object.

public Set<String>
getResourcePaths(String
the partial path used to match the resources, which must start with a /
path
)

Implements jakarta.servlet.ServletContext.getResourcePaths.

Returns a directory-like listing of all the paths to resources within the web application whose longest sub-path matches the supplied path argument.

public String
getResponseCharacterEncoding()

Implements jakarta.servlet.ServletContext.getResponseCharacterEncoding.

Get the default character encoding for writing response bodies.

public String
getServerInfo()

Implements jakarta.servlet.ServletContext.getServerInfo.

Returns the name and version of the servlet container on which the servlet is running.

public String
getServletContextName()

Implements jakarta.servlet.ServletContext.getServletContextName.

Returns the name of this web application corresponding to this ServletContext as specified in the deployment descriptor for this web application by the display-name element.

public ServletRegistration
getServletRegistration(String
The name of the Servlet of interest
servletName
)

Implements jakarta.servlet.ServletContext.getServletRegistration.

Obtain the details of the named servlet.

public Map<String, ? extends ServletRegistration>
getServletRegistrations()

Implements jakarta.servlet.ServletContext.getServletRegistrations.

Obtain a Map of servlet names to servlet registrations for all servlets registered with this context.

public SessionCookieConfig
public int
getSessionTimeout()

Implements jakarta.servlet.ServletContext.getSessionTimeout.

Get the default session timeout.

public String
getVirtualServerName()

Implements jakarta.servlet.ServletContext.getVirtualServerName.

Get the primary name of the virtual host on which this context is deployed.

public void
log(String
a String specifying the message to be written to the log file
message
)

Implements jakarta.servlet.ServletContext.log.

Writes the specified message to a servlet log file, usually an event log.

public void
log(String
a String that describes the error or exception
message
,
Throwable
the Throwable error or exception
throwable
)

Implements jakarta.servlet.ServletContext.log.

Writes an explanatory message and a stack trace for a given Throwable exception to the servlet log file.

private void
public void
removeAttribute(String
a String specifying the name of the attribute to be removed
name
)

Implements jakarta.servlet.ServletContext.removeAttribute.

Removes the attribute with the given name from the servlet context.

public void
setAttribute(String
a String specifying the name of the attribute
name
,
Object
an Object representing the attribute to be bound
value
)

Implements jakarta.servlet.ServletContext.setAttribute.

Binds an object to a given attribute name in this servlet context.

pack-priv void
setAttributeReadOnly(String name)

Set an attribute as read only.

public boolean
setInitParameter(String
Name of initialisation parameter
name
,
String
Value for initialisation parameter
value
)

Implements jakarta.servlet.ServletContext.setInitParameter.

Set the given initialisation parameter to the given value.

protected void
public void
setRequestCharacterEncoding(String
The name of the character encoding to use
encoding
)

Implements jakarta.servlet.ServletContext.setRequestCharacterEncoding.

Set the default character encoding to use for reading request bodies.

public void
setResponseCharacterEncoding(String
The name of the character encoding to use
encoding
)

Implements jakarta.servlet.ServletContext.setResponseCharacterEncoding.

Set the default character encoding to use for writing response bodies.

public void
setSessionTimeout(int
The new default session timeout in minutes.
sessionTimeout
)

Implements jakarta.servlet.ServletContext.setSessionTimeout.

Set the default session timeout.

public void
setSessionTrackingModes(Set<SessionTrackingMode>
The session tracking modes to use for this web application
sessionTrackingModes
)

Implements jakarta.servlet.ServletContext.setSessionTrackingModes.

Configures the available session tracking modes for this web application.

pack-priv static String
private String
validateResourcePath(String path, boolean addMissingInitialSlash)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait