Top Inners Fields Constructors Methods
io.undertow.servlet.spec

public Class ServletContextImpl

extends Object
implements ServletContext
Class Inheritance
All Implemented Interfaces
jakarta.servlet.ServletContext
Imports
io.undertow.Version, io.undertow.server.HandlerWrapper, .HttpServerExchange, io.undertow.server.handlers.cache.LRUCache, io.undertow.server.handlers.resource.Resource, io.undertow.server.session.PathParameterSessionConfig, .Session, .SessionConfig, .SessionManager, .SslSessionConfig, io.undertow.servlet.UndertowServletLogger, .UndertowServletMessages, io.undertow.servlet.api.Deployment, .DeploymentInfo, .DeploymentManager, .FilterInfo, .HttpMethodSecurityInfo, .InstanceFactory, .ListenerInfo, .SecurityInfo, .ServletContainer, .ServletInfo, .ServletSecurityInfo, .SessionConfigWrapper, .ThreadSetupHandler, .TransportGuaranteeType, io.undertow.servlet.core.ApplicationListeners, .ManagedListener, .ManagedServlet, io.undertow.servlet.handlers.ServletChain, .ServletHandler, .ServletRequestContext, io.undertow.servlet.util.ImmediateInstanceFactory, .IteratorEnumeration, io.undertow.util.AttachmentKey, .CanonicalPathUtils, jakarta.annotation.security.DeclareRoles, .RunAs, jakarta.servlet.DispatcherType, .Filter, .FilterRegistration, .MultipartConfigElement, .ReadListener, .RequestDispatcher, .Servlet, .ServletContext, .ServletContextListener, .ServletException, .ServletRegistration, .ServletRequest, .SessionTrackingMode, .WriteListener, jakarta.servlet.annotation.HttpMethodConstraint, .MultipartConfig, .ServletSecurity, jakarta.servlet.descriptor.JspConfigDescriptor, java.io.BufferedInputStream, .File, .FileInputStream, .FileNotFoundException, .IOException, .InputStream, java.net.MalformedURLException, .URL, java.nio.file.Files, .Path, java.security.AccessController, .PrivilegedAction, java.util.Arrays, .Collections, .EnumSet, .Enumeration, .EventListener, .HashMap, .HashSet, .List, .Locale, .Map, .Set, java.util.concurrent.ConcurrentHashMap, .ConcurrentMap

Author
Stuart Douglas

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
pack-priv static class
ServletContextImpl.ServletContextSessionConfig

This is a bit of a hack to make sure than an invalidated session ID is not re-used.

Field Summary

Modifier and TypeField and Description
private final ConcurrentMap<String, Object>
private final LRUCache<String, ContentTypeInfo>
private volatile int
private volatile Set<SessionTrackingMode>
private final Deployment
private volatile DeploymentInfo
private int
private int
private volatile boolean
private volatile ThreadSetupHandler.Action<Void, ThreadSetupHandler.Action<Void, Object>>
private volatile ThreadSetupHandler.Action<Void, ReadListener>
private volatile ThreadSetupHandler.Action<Void, ReadListener>
private volatile ThreadSetupHandler.Action<Void, WriteListener>
private volatile ThreadSetupHandler.Action<Void, Runnable>
private final ServletContainer
private final AttachmentKey<HttpSessionImpl>
private volatile SessionConfig
private final SessionCookieConfigImpl
private volatile Set<SessionTrackingMode>

Constructor Summary

AccessConstructor and Description
public
ServletContextImpl(final ServletContainer servletContainer, final Deployment deployment)

Method Summary

Modifier and TypeMethod and Description
public FilterRegistration.Dynamic
addFilter(final String
the name of the filter
filterName
,
final String
the fully qualified class name of the filter
className
)

Implements jakarta.servlet.ServletContext.addFilter.

Adds the filter with the given name and class name to this servlet context.

public FilterRegistration.Dynamic
addFilter(final String
the name of the filter
filterName
,
final Filter
the filter instance to register
filter
)

Implements jakarta.servlet.ServletContext.addFilter.

Registers the given filter instance with this ServletContext under the given filterName.

public FilterRegistration.Dynamic
addFilter(final String
the name of the filter
filterName
,
final Class<? extends Filter>
the class object from which the filter will be instantiated
filterClass
)

Implements jakarta.servlet.ServletContext.addFilter.

Adds the filter with the given name and class type to this servlet context.

public ServletRegistration.Dynamic
addJspFile(String
the name of the servlet
servletName
,
String
the full path to a JSP file within the web application beginning with a `/'.
jspFile
)

Implements jakarta.servlet.ServletContext.addJspFile.

Adds the servlet with the given jsp file to this servlet context.

public void
addListener(final String
the fully qualified class name of the listener
className
)

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

Adds the listener with the given class name to this ServletContext.

public <T extends EventListener> void
addListener(final T
the listener to be added
t
)

Implements jakarta.servlet.ServletContext.addListener.

Adds the given listener to this ServletContext.

public void
addListener(final Class<? extends EventListener>
the listener class to be instantiated
listenerClass
)

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

Adds a listener of the given class type to this ServletContext.

pack-priv void
addMappingForServletNames(FilterInfo filterInfo, final EnumSet<DispatcherType> dispatcherTypes, final boolean isMatchAfter, final String... servletNames)

pack-priv void
addMappingForUrlPatterns(FilterInfo filterInfo, final EnumSet<DispatcherType> dispatcherTypes, final boolean isMatchAfter, final String... urlPatterns)

public ServletRegistration.Dynamic
addServlet(final String
the name of the servlet
servletName
,
final String
the fully qualified class name of the servlet
className
)

Implements jakarta.servlet.ServletContext.addServlet.

Adds the servlet with the given name and class name to this servlet context.

public ServletRegistration.Dynamic
addServlet(final String servletName, final String className, List<HandlerWrapper> wrappers)

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

Implements jakarta.servlet.ServletContext.addServlet.

Registers the given servlet instance with this ServletContext under the given servletName.

public ServletRegistration.Dynamic
addServlet(final String
the name of the servlet
servletName
,
final Class<? extends Servlet>
the class object from which the servlet will be instantiated
servletClass
)

Implements jakarta.servlet.ServletContext.addServlet.

Adds the servlet with the given name and class type to this servlet context.

public <T extends Filter> T
createFilter(final Class<T>
the Filter class to instantiate
clazz
)

Implements jakarta.servlet.ServletContext.createFilter.

Instantiates the given Filter class.

public <T extends EventListener> T
createListener(final Class<T>
the EventListener class to instantiate
clazz
)

Implements jakarta.servlet.ServletContext.createListener.

Instantiates the given EventListener class.

public <T extends Servlet> T
createServlet(final Class<T>
the Servlet class to instantiate
clazz
)

Implements jakarta.servlet.ServletContext.createServlet.

Instantiates the given Servlet class.

public void
declareRoles(final String...
the role names being declared
roleNames
)

Implements jakarta.servlet.ServletContext.declareRoles.

Declares role names that are tested using isUserInRole.

public void
private void
private void
private void
public Object
getAttribute(final 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 ServletContext.

public ClassLoader
getClassLoader()

Implements jakarta.servlet.ServletContext.getClassLoader.

Gets the class loader of the web application represented by this ServletContext.

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

Implements jakarta.servlet.ServletContext.getContext.

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

public String
getContextPath()

Implements jakarta.servlet.ServletContext.getContextPath.

Returns the context path of the web application.

public Set<SessionTrackingMode>
getDefaultSessionTrackingModes()

Implements jakarta.servlet.ServletContext.getDefaultSessionTrackingModes.

Gets the session tracking modes that are supported by default for this ServletContext.

public Deployment
private DeploymentInfo
public int
getEffectiveMajorVersion()

Implements jakarta.servlet.ServletContext.getEffectiveMajorVersion.

Gets the major version of the Servlet specification that the application represented by this ServletContext is based on.

public int
getEffectiveMinorVersion()

Implements jakarta.servlet.ServletContext.getEffectiveMinorVersion.

Gets the minor version of the Servlet specification that the application represented by this ServletContext is based on.

public Set<SessionTrackingMode>
getEffectiveSessionTrackingModes()

Implements jakarta.servlet.ServletContext.getEffectiveSessionTrackingModes.

Gets the session tracking modes that are in effect for this ServletContext.

public FilterRegistration
getFilterRegistration(final String
the name of a filter
filterName
)

Implements jakarta.servlet.ServletContext.getFilterRegistration.

Gets the FilterRegistration corresponding to the filter with the given filterName.

public Map<String, ? extends FilterRegistration>
getFilterRegistrations()

Implements jakarta.servlet.ServletContext.getFilterRegistrations.

Gets a (possibly empty) Map of the FilterRegistration objects (keyed by filter name) corresponding to all filters registered with this ServletContext.

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

Implements jakarta.servlet.ServletContext.getJspConfigDescriptor.

Gets the <jsp-config> related configuration that was aggregated from the web.xml and web-fragment.xml descriptor files of the web application represented by this ServletContext.

public int
getMajorVersion()

Implements jakarta.servlet.ServletContext.getMajorVersion.

Returns the major version of Jakarta Servlet specification that this container supports.

public String
getMimeType(final String
a String specifying the name of a file
file
)

Implements jakarta.servlet.ServletContext.getMimeType.

Returns the MIME type of the specified file, or null if the MIME type is not known.

public int
getMinorVersion()

Implements jakarta.servlet.ServletContext.getMinorVersion.

Returns the minor version of Jakarta Servlet specification that this container supports.

public RequestDispatcher
getNamedDispatcher(final String
a String specifying the name of a servlet to wrap
name
)

Implements jakarta.servlet.ServletContext.getNamedDispatcher.

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

public String
getRealPath(final String
the virtual path to be translated to a real path
path
)

Implements jakarta.servlet.ServletContext.getRealPath.

Gets the real path corresponding to the given virtual path.

public String
getRequestCharacterEncoding()

Implements jakarta.servlet.ServletContext.getRequestCharacterEncoding.

Gets the request character encoding that are supported by default for this ServletContext.

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(final 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 the given path.

public InputStream
getResourceAsStream(final 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(final 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.

Gets the response character encoding that are supported by default for this ServletContext.

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(final String
the name of a servlet
servletName
)

Implements jakarta.servlet.ServletContext.getServletRegistration.

Gets the ServletRegistration corresponding to the servlet with the given servletName.

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

Implements jakarta.servlet.ServletContext.getServletRegistrations.

Gets a (possibly empty) Map of the ServletRegistration objects (keyed by servlet name) corresponding to all servlets registered with this ServletContext.

public HttpSessionImpl

Returns:

The session
getSession
(final String
The session ID
sessionId
)

Gets the session with the specified ID if it exists

public HttpSessionImpl
getSession(final ServletContextImpl originalServletContext, final HttpServerExchange exchange, boolean create)

public HttpSessionImpl
getSession(final HttpServerExchange exchange, boolean create)

Gets the session

public SessionConfig
public SessionCookieConfigImpl
getSessionCookieConfig()

Implements jakarta.servlet.ServletContext.getSessionCookieConfig.

Gets the SessionCookieConfig object through which various properties of the session tracking cookies created on behalf of this ServletContext may be configured.

public int
getSessionTimeout()

Implements jakarta.servlet.ServletContext.getSessionTimeout.

Gets the session timeout in minutes that are supported by default for this ServletContext.

public String
getVirtualServerName()

Implements jakarta.servlet.ServletContext.getVirtualServerName.

Returns the configuration name of the logical host on which the ServletContext is deployed.

public void
pack-priv void
pack-priv void
pack-priv void
pack-priv void
pack-priv void
pack-priv boolean
public void
log(final String
a String specifying the message to be written to the log file
msg
)

Implements jakarta.servlet.ServletContext.log.

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

public void
log(final String
a String that describes the error or exception
message
,
final 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.

pack-priv ContentTypeInfo
private void
public void
removeAttribute(final 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 this ServletContext.

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

Implements jakarta.servlet.ServletContext.setAttribute.

Binds an object to a given attribute name in this ServletContext.

public void
public boolean
setInitParameter(final String
the name of the context initialization parameter to set
name
,
final String
the value of the context initialization parameter to set
value
)

Implements jakarta.servlet.ServletContext.setInitParameter.

Sets the context initialization parameter with the given name and value on this ServletContext.

public void
setRequestCharacterEncoding(String
request character encoding
encoding
)

Implements jakarta.servlet.ServletContext.setRequestCharacterEncoding.

Sets the request character encoding for this ServletContext.

public void
setResponseCharacterEncoding(String
response character encoding
encoding
)

Implements jakarta.servlet.ServletContext.setResponseCharacterEncoding.

Sets the response character encoding for this ServletContext.

public void
setSessionTimeout(int
session timeout in minutes
sessionTimeout
)

Implements jakarta.servlet.ServletContext.setSessionTimeout.

Sets the session timeout in minutes for this ServletContext.

public void
setSessionTrackingModes(final Set<SessionTrackingMode>
the set of session tracking modes to become effective for this ServletContext
sessionTrackingModes
)

Implements jakarta.servlet.ServletContext.setSessionTrackingModes.

Sets the session tracking modes that are to become effective for this ServletContext.

public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait