Top Description Inners Fields Constructors Methods
org.eclipse.jetty.ee10.servlet

public Class ServletContextHandler

extends ContextHandler
Class Inheritance
Annotations
@ManagedObject:Servlet Context Handler
Imports
java.io.File, .IOException, .InputStream, java.net.MalformedURLException, .URI, .URL, java.nio.charset.Charset, java.nio.file.Files, .Path, java.util.ArrayList, .Arrays, .Collections, .EnumSet, .Enumeration, .EventListener, .HashMap, .HashSet, .List, .Locale, .Map, .Objects, .Set, java.util.concurrent.CopyOnWriteArrayList, .TimeUnit, java.util.function.Supplier, jakarta.servlet.DispatcherType, .Filter, .FilterRegistration, .RequestDispatcher, .Servlet, .ServletContainerInitializer, .ServletContextAttributeEvent, .ServletContextAttributeListener, .ServletContextEvent, .ServletContextListener, .ServletException, .ServletRegistration, .ServletRequestAttributeListener, .ServletRequestEvent, .ServletRequestListener, .ServletSecurityElement, .SessionCookieConfig, .SessionTrackingMode, jakarta.servlet.descriptor.JspConfigDescriptor, .JspPropertyGroupDescriptor, .TaglibDescriptor, jakarta.servlet.http.HttpServlet, .HttpServletRequest, .HttpServletResponse, .HttpSessionActivationListener, .HttpSessionAttributeListener, .HttpSessionBindingListener, .HttpSessionIdListener, .HttpSessionListener, org.eclipse.jetty.ee10.servlet.ServletContextResponse.EncodingFrom, .ServletContextResponse.OutputType, org.eclipse.jetty.ee10.servlet.security.ConstraintAware, .ConstraintMapping, .ConstraintSecurityHandler, org.eclipse.jetty.http.HttpURI, org.eclipse.jetty.http.pathmap.MatchedResource, org.eclipse.jetty.security.SecurityHandler, org.eclipse.jetty.server.Context, .Handler, .Request, .Response, org.eclipse.jetty.server.handler.ContextHandler, .ContextHandlerCollection, .ContextRequest, .ContextResponse, org.eclipse.jetty.session.AbstractSessionManager, .ManagedSession, .SessionManager, org.eclipse.jetty.util.Attributes, .Callback, .DecoratedObjectFactory, .DeprecationWarning, .ExceptionUtil, .Loader, .StringUtil, .URIUtil, org.eclipse.jetty.util.annotation.ManagedAttribute, .ManagedObject, org.eclipse.jetty.util.component.ClassLoaderDump, .ContainerLifeCycle, .Dumpable, .DumpableCollection, .Environment, .LifeCycle, org.eclipse.jetty.util.resource.Resource, .ResourceFactory, .Resources, org.eclipse.jetty.util.security.SecurityUtils, org.slf4j.Logger, .LoggerFactory

Servlet Context.

This extension to the ContextHandler allows for simple construction of a context with ServletHandler and optionally session and security handlers, et.

  new ServletContext("/context",Context.SESSIONS|Context.NO_SECURITY);

This class should have been called ServletContext, but this would have cause confusion with jakarta.servlet.ServletContext.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
public static class
public static class
public static interface
public static class
ServletContextHandler.ServletContainerInitializerStarter

Bean that is added to the ServletContextHandler to start all of the ServletContainerInitializers by starting their corresponding ServletContainerInitializerHolders when this bean is itself started.

public class
public static interface
ServletContextHandler.ServletContextScopeListener

Listener for all threads entering context scope, including async IO callbacks

public static interface
ServletContextHandler.ServletRequestInfo

The interface used by ServletApiRequest to access the ServletContextRequest without access to the unwrapped Request methods.

public static interface
ServletContextHandler.ServletResponseInfo

The interface used by ServletApiResponse to access the ServletContextResponse without access to the unwrapped Response methods.

public class
public static class

Field Summary

Modifier and TypeField and Description
public static final Environment
private final List<ServletContextHandler.ServletContextScopeListener>
private String
protected ServletContextHandler.ContextStatus
private String
private String
private Class<? extends SecurityHandler>
private final List<ServletContextListener>
private final Set<EventListener>
private final Map<String, String>
protected JspConfigDescriptor
private Map<String, String>
private Logger
private int
private int
protected final DecoratedObjectFactory
protected int
private final List<EventListener>
protected SecurityHandler
private final ServletContextHandler.ServletContextApi
private final List<ServletContextAttributeListener>
private final List<ServletContextListener>
protected ServletHandler
private final List<ServletRequestAttributeListener>
private final List<ServletRequestListener>
protected SessionHandler
private boolean
private boolean
private String[]
public static final int
public static final int
public static final int
public static final int
private static final Logger
public static final String
public static final String
public static final int
public static final int
public static final int
public static final Class<?>[]
public static final int
Inherited from org.eclipse.jetty.server.handler.ContextHandler:
MANAGED_ATTRIBUTES

Constructor Summary

AccessConstructor and Description
public
public
public
ServletContextHandler(int options)

public
ServletContextHandler(String contextPath, int options)

public
ServletContextHandler(String contextPath, boolean sessions, boolean security)

public
ServletContextHandler(SessionHandler sessionHandler, SecurityHandler securityHandler, ServletHandler servletHandler, ErrorHandler errorHandler)

public
ServletContextHandler(String contextPath, SessionHandler sessionHandler, SecurityHandler securityHandler, ServletHandler servletHandler, ErrorHandler errorHandler)

public
ServletContextHandler(String contextPath, SessionHandler sessionHandler, SecurityHandler securityHandler, ServletHandler servletHandler, ErrorHandler errorHandler, int options)

Method Summary

Modifier and TypeMethod and Description
public boolean
public void
addFilter(FilterHolder
the filter holder
holder
,
String
the path spec
pathSpec
,
EnumSet<DispatcherType>
the dispatcher types for this filter
dispatches
)

Convenience method to add a filter

public FilterHolder

Returns:

the FilterHolder that was created
addFilter
(Class<? extends Filter>
the filter class
filterClass
,
String
the path spec
pathSpec
,
EnumSet<DispatcherType>
the dispatcher types for this filter
dispatches
)

Convenience method to add a filter

public FilterHolder

Returns:

the FilterHolder that was created
addFilter
(String
the filter class name
filterClass
,
String
the path spec
pathSpec
,
EnumSet<DispatcherType>
the dispatcher types for this filter
dispatches
)

Convenience method to add a filter

public FilterHolder

Returns:

the FilterHolder that was created
addFilter
(Filter
the filter instance
filter
,
String
the path spec
pathSpec
,
EnumSet<DispatcherType>
the dispatcher types for this filter
dispatches
)

Convenience method to add a servlet.

public void
addLocaleEncoding(String locale, String encoding)

protected void
addProgrammaticListener(EventListener
the programmatic listener to add
listener
)

Apply any necessary restrictions on a programmatic added listener.

protected void
addRoles(String...
role names to add
roleNames
)

delegate for ServletContext.declareRole method

public ServletHolder

Returns:

the ServletHolder for the added servlet
addServlet
(String
the servlet class name
className
,
String
the path spec to map servlet to
pathSpec
)

Convenience method to add a servlet.

public ServletHolder

Returns:

the ServletHolder for the added servlet
addServlet
(Class<? extends Servlet>
the servlet class
servlet
,
String
the path spec to map servlet to
pathSpec
)

Convenience method to add a servlet.

public void
addServlet(ServletHolder
the servlet holder
servlet
,
String
the path spec
pathSpec
)

Convenience method to add a servlet.

public ServletHolder

Returns:

the ServletHolder for the added servlet
addServlet
(HttpServlet
the servlet instance
servlet
,
String
the path spec
pathSpec
)

Convenience method to add a servlet.

public ServletContainerInitializerHolder

Returns:

the ServletContainerInitializerHolder that was created
addServletContainerInitializer
(ServletContainerInitializer
the ServletContainerInitializer to register.
sci
)

Convenience method to programmatically add a ServletContainerInitializer.

public ServletContainerInitializerHolder

Returns:

the ServletContainerInitializerHolder that was created
addServletContainerInitializer
(ServletContainerInitializer
the ServletContainerInitializer to register.
sci
,
Class<?>...
the Set of application classes.
classes
)

Convenience method to programmatically add a ServletContainerInitializer.

public void
addServletContainerInitializer(ServletContainerInitializerHolder...
the ServletContainerInitializerHolders
sciHolders
)

Convenience method to programmatically add a list of ServletContainerInitializer.

public void
public void
public void
contextDestroyed()

Call the ServletContextListeners with contextDestroyed.

public void
contextInitialized()

Call the ServletContextListeners contextInitialized methods.

pack-priv void
pack-priv void
pack-priv void
private void
protected void
doStart()

Overrides org.eclipse.jetty.server.handler.ContextHandler.doStart.

Starts the managed lifecycle beans in the order they were added.

protected void
doStop()

Overrides org.eclipse.jetty.server.handler.ContextHandler.doStop.

Stops the managed lifecycle beans in the reverse order they were added.

public void
dump(Appendable
The appendable to dump to
out
,
String
The indent to apply after any new lines.
indent
)

Overrides org.eclipse.jetty.server.handler.ContextHandler.dump.

Implements org.eclipse.jetty.util.component.Dumpable.dump.

Dump this object (and children) into an Appendable using the provided indent after any new lines.

protected ServletRegistration.Dynamic

Returns:

the ServletRegistration.Dynamic
dynamicHolderAdded
(ServletHolder
new holder created through the api.
holder
)

notification that a ServletRegistration has been created so we can track the annotations

public ServletContextHandler.ServletScopedContext
public String
getContextPathEncoded()

Returns: Returns the encoded contextPath.

public static ServletContext
public static ServletContextHandler
public String
public String
public Class<? extends SecurityHandler>

Returns:

the defaultSecurityHandlerClass
getDefaultSecurityHandlerClass
()

Get the defaultSecurityHandlerClass.

public String
public Enumeration<String>
public Map<String, String>
getInitParams()

Returns: Returns the initParams.

public Invocable.InvocationType
public String
public String

Returns:

a String representing the character encoding for the locale or null if none found.
getLocaleEncoding
(Locale
a Locale value
locale
)

Get the character encoding for a locale.

public Map<String, String>

Returns:

a map of all the locale encodings: key is name of the locale and value is the char encoding
getLocaleEncodings
()

Get all of the locale encodings

public Logger
private String
public int
public int
public DecoratedObjectFactory

Returns:

The DecoratedObjectFactory
getObjectFactory
()

The DecoratedObjectFactory for use by IoC containers (weld / spring / etc)

public String

Returns:

Returns the encoded contextPath, or empty string for root context
getRequestContextPath
()

Get the context path in a form suitable to be returned from HttpServletRequest#getContextPath() or jakarta.servlet.ServletContext#getContextPath().

public Resource

Returns:

the resource, or null if not available.
getResource
(String
the path within the base resource to attempt to get
pathInContext
)

Attempt to get a Resource from the Context.

public Set<String>
public SecurityHandler
getSecurityHandler()

Returns: Returns the securityHandler.

private static Object
public static ServletContext
public ServletContext
public static ServletContextHandler
public static ServletContextHandler
public ServletHandler
getServletHandler()

Returns: Returns the servletHandler.

public SessionHandler
getSessionHandler()

Returns: Returns the sessionHandler.

public String[]
getWelcomeFiles()

Returns: The names of the files which the server should consider to be welcome files in this context.

protected boolean
public void
insertHandler(Handler.Singleton
the Handler to insert
handler
)

Overrides default org.eclipse.jetty.server.Handler.Singleton.insertHandler.

Insert a HandlerWrapper before the first Session, Security or ServletHandler but after any other HandlerWrappers.

public boolean
public boolean
public boolean
public Class<?>
loadClass(String className)

protected ContextHandler.ScopedContext
public Resource

Returns:

the Resource for that url
newResource
(URL
the url to convert to a Resource
url
)

Convert URL to Resource wrapper for ResourceFactory#newResource(URL) enables extensions to provide alternate resource implementations.

public Resource

Returns:

the Resource for that URI
newResource
(URI
the URI to convert to a Resource
uri
)

Convert URL to Resource wrapper for ResourceFactory#newResource(URL) enables extensions to provide alternate resource implementations.

public Resource

Returns:

The Resource for the URL/path
newResource
(String
The URL or path to convert
urlOrPath
)

Convert a URL or path to a Resource.

protected SecurityHandler
public ServletContextHandler.ServletContextApi
protected ServletContextRequest
newServletContextRequest(ServletChannel servletChannel, Request request, Response response, String decodedPathInContext, MatchedResource<ServletHandler.MappedServlet> matchedResource)

protected ServletHandler
protected SessionHandler
protected void
notifyEnterScope(Request
A request that is applicable to the scope, or null
request
)

Overrides org.eclipse.jetty.server.handler.ContextHandler.notifyEnterScope.

protected void
notifyExitScope(Request
A request that is applicable to the scope, or null
request
)

Overrides org.eclipse.jetty.server.handler.ContextHandler.notifyExitScope.

private void
public boolean
private void
protected void
protected void
public void
public void
public void
public void
setDefaultSecurityHandlerClass(Class<? extends SecurityHandler>
the defaultSecurityHandlerClass to set
defaultSecurityHandlerClass
)

Set the defaultSecurityHandlerClass.

public void
public String
public void
setLogger(Logger logger)

public void
setMaxFormContentSize(int
the maximum size of the form content (in bytes)
maxSize
)

Set the maximum size of a form post, to protect against DOS attacks from large forms.

public void
setMaxFormKeys(int
the maximum number of form keys
max
)

Set the maximum number of form Keys to protect against DOS attack from crafted hash keys.

public void
setSecurityHandler(SecurityHandler
The SecurityHandler to set on this context.
securityHandler
)

public void
setServletHandler(ServletHandler
The servletHandler to set.
servletHandler
)

public Set<String>

Returns:

the set of exact URL mappings currently associated with the registration that are also present in the web.xml security constraints and thus will be unaffected by this call.
setServletSecurity
(ServletRegistration.Dynamic
ServletRegistration.Dynamic instance that setServletSecurity was called on
registration
,
ServletSecurityElement
new security info
servletSecurityElement
)

Delegate for ServletRegistration.Dynamic.setServletSecurity method

public void
setSessionHandler(SessionHandler
The sessionHandler to set.
sessionHandler
)

public void
setTempDirectory(File
A directory. If it does not exist, it must be able to be created during start.
tempDirectory
)

Overrides org.eclipse.jetty.server.handler.ContextHandler.setTempDirectory.

Set the temporary directory returned by ScopedContext#getTempDirectory().

public void
setUsingSecurityManager(boolean usingSecurityManager)

public void
protected void
startContext()

Finish constructing handlers and link them together.

protected void
private ContextRequest
wrapNoServlet(Request request, Response response)

protected ContextRequest
protected ContextResponse
Inherited from org.eclipse.jetty.server.handler.ContextHandler:
addAliasCheckaddVirtualHostscheckAliascheckVirtualHostclearAliasChecksclearAttributescreateTempDirectorydestroyenterScopeexitScopegetAliasChecksgetAllowNullPathInContextgetAttributegetAttributeNameSetgetBaseResourcegetClassLoadergetClassPathgetContextHandlergetContextPathgetCurrentContextgetCurrentContextgetCurrentContextHandlergetDisplayNamegetErrorHandlergetMimeTypesgetProtectedTargetsgetTempDirectorygetVirtualHostshandlehandleMovedPermanentlyhandleUnavailableisAvailableisProtectedTargetisTempDirectoryPersistentremoveAttributeremoveVirtualHostssetAliasCheckssetAllowNullPathInContextsetAttributesetAvailablesetBaseResourcesetBaseResourceAsPathsetBaseResourceAsStringsetClassLoadersetDisplayNamesetErrorHandlersetProtectedTargetssetServersetTempDirectoryPersistentsetVirtualHoststoString