Package org.eclipse.jetty.servlet
Class ServletHandler
- java.lang.Object
-
- All Implemented Interfaces:
Handler
,HandlerContainer
,Container
,Destroyable
,Dumpable
,Dumpable.DumpableContainer
,LifeCycle
@ManagedObject("Servlet Handler") @Deprecated(since="2021-05-27") public class ServletHandler extends ScopedHandler
Deprecated.The Eclipse Jetty and Apache Felix Http Jetty packages are no longer supported.Servlet HttpHandler.This handler maps requests to servlets that implement the javax.servlet.http.HttpServlet API.
This handler does not implement the full J2EE features and is intended to be used directly when a full web application is not required. If a Web application is required, then this handler should be used as part of a
org.eclipse.jetty.webapp.WebAppContext
.Unless run as part of a
ServletContextHandler
or derivative, theinitialize()
method must be called manually after start().
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ServletHandler.Default404Servlet
Deprecated.-
Nested classes/interfaces inherited from class org.eclipse.jetty.server.handler.AbstractHandler
AbstractHandler.ErrorDispatchHandler
-
Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
AbstractLifeCycle.AbstractLifeCycleListener
-
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Container
Container.InheritedListener, Container.Listener
-
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable
Dumpable.DumpableContainer
-
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle
LifeCycle.Listener
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
__DEFAULT_SERVLET
Deprecated.
-
Constructor Summary
Constructors Constructor Description ServletHandler()
Deprecated.Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description FilterHolder
addFilter(java.lang.String className, java.lang.String pathSpec, java.util.EnumSet<DispatcherType> dispatches)
Deprecated.useaddFilterWithMapping(Class, String, EnumSet)
insteadvoid
addFilter(FilterHolder filter)
Deprecated.Convenience method to add a preconstructed FilterHoldervoid
addFilter(FilterHolder filter, FilterMapping filterMapping)
Deprecated.Convenience method to add a filter and mappingvoid
addFilterMapping(FilterMapping mapping)
Deprecated.Convenience method to add a preconstructed FilterMappingFilterHolder
addFilterWithMapping(java.lang.Class<? extends Filter> filter, java.lang.String pathSpec, int dispatches)
Deprecated.Convenience method to add a filter.FilterHolder
addFilterWithMapping(java.lang.Class<? extends Filter> filter, java.lang.String pathSpec, java.util.EnumSet<DispatcherType> dispatches)
Deprecated.Convenience method to add a filter.FilterHolder
addFilterWithMapping(java.lang.String className, java.lang.String pathSpec, int dispatches)
Deprecated.Convenience method to add a filter.FilterHolder
addFilterWithMapping(java.lang.String className, java.lang.String pathSpec, java.util.EnumSet<DispatcherType> dispatches)
Deprecated.Convenience method to add a filter.void
addFilterWithMapping(FilterHolder holder, java.lang.String pathSpec, int dispatches)
Deprecated.Convenience method to add a filter.void
addFilterWithMapping(FilterHolder holder, java.lang.String pathSpec, java.util.EnumSet<DispatcherType> dispatches)
Deprecated.Convenience method to add a filter.void
addListener(ListenerHolder listener)
Deprecated.Add a holder for a listenervoid
addServlet(ServletHolder holder)
Deprecated.Convenience method to add a pre-constructed ServletHolder.void
addServletMapping(ServletMapping mapping)
Deprecated.Convenience method to add a pre-constructed ServletMapping.ServletHolder
addServletWithMapping(java.lang.Class<? extends Servlet> servlet, java.lang.String pathSpec)
Deprecated.Convenience method to add a servlet.ServletHolder
addServletWithMapping(java.lang.String className, java.lang.String pathSpec)
Deprecated.Convenience method to add a servlet.void
addServletWithMapping(ServletHolder servlet, java.lang.String pathSpec)
Deprecated.Convenience method to add a servlet.void
doHandle(java.lang.String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response)
Deprecated.Do the handler work within the scope.void
doScope(java.lang.String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response)
Deprecated.Scope the handlervoid
dump(java.lang.Appendable out, java.lang.String indent)
Deprecated.Dump this object (and children) into an Appendable using the provided indent after any new lines.FilterHolder
getFilter(java.lang.String name)
Deprecated.FilterMapping[]
getFilterMappings()
Deprecated.FilterHolder[]
getFilters()
Deprecated.MappedResource<ServletHolder>
getHolderEntry(java.lang.String target)
Deprecated.ListenerHolder[]
getListeners()
Deprecated.MappedResource<ServletHolder>
getMappedServlet(java.lang.String target)
Deprecated.ServletHolder matching path.int
getMaxFilterChainsCacheSize()
Deprecated.ServletHolder
getServlet(java.lang.String name)
Deprecated.ServletContext
getServletContext()
Deprecated.ServletContextHandler
getServletContextHandler()
Deprecated.ServletMapping
getServletMapping(java.lang.String pathSpec)
Deprecated.Get the ServletMapping matching the pathServletMapping[]
getServletMappings()
Deprecated.ServletHolder[]
getServlets()
Deprecated.java.util.List<ServletHolder>
getServlets(java.lang.Class<?> clazz)
Deprecated.void
initialize()
Deprecated.Initialize filters and load-on-startup servlets.boolean
isAllowDuplicateMappings()
Deprecated.boolean
isAvailable()
Deprecated.boolean
isDumpable(java.lang.Object o)
Deprecated.boolean
isEnsureDefaultServlet()
Deprecated.boolean
isFilterChainsCached()
Deprecated.boolean
isInitialized()
Deprecated.boolean
isStartWithUnavailable()
Deprecated.FilterHolder
newFilterHolder(Source source)
Deprecated.ListenerHolder
newListenerHolder(Source source)
Deprecated.ServletHolder
newServletHolder(Source source)
Deprecated.Add a new servlet holdervoid
prependFilterMapping(FilterMapping mapping)
Deprecated.Convenience method to add a preconstructed FilterMappingvoid
setAllowDuplicateMappings(boolean allowDuplicateMappings)
Deprecated.void
setEnsureDefaultServlet(boolean ensureDefaultServlet)
Deprecated.void
setFilterChainsCached(boolean filterChainsCached)
Deprecated.void
setFilterMappings(FilterMapping[] filterMappings)
Deprecated.void
setFilters(FilterHolder[] holders)
Deprecated.void
setListeners(ListenerHolder[] listeners)
Deprecated.void
setMaxFilterChainsCacheSize(int maxFilterChainsCacheSize)
Deprecated.Set the maximum filter chain cache size.void
setServletMappings(ServletMapping[] servletMappings)
Deprecated.void
setServlets(ServletHolder[] holders)
Deprecated.Set Servlets.java.util.Set<java.lang.String>
setServletSecurity(ServletRegistration.Dynamic registration, ServletSecurityElement servletSecurityElement)
Deprecated.void
setStartWithUnavailable(boolean start)
Deprecated.-
Methods inherited from class org.eclipse.jetty.server.handler.ScopedHandler
handle, nextHandle, nextScope
-
Methods inherited from class org.eclipse.jetty.server.handler.HandlerWrapper
destroy, getHandler, getHandlers, insertHandler, setHandler
-
Methods inherited from class org.eclipse.jetty.server.handler.AbstractHandlerContainer
findContainerOf, getChildHandlerByClass, getChildHandlers, getChildHandlersByClass, setServer
-
Methods inherited from class org.eclipse.jetty.server.handler.AbstractHandler
getServer
-
Methods inherited from class org.eclipse.jetty.util.component.ContainerLifeCycle
addBean, addBean, addEventListener, addManaged, contains, dump, dump, dump, dump, dumpObject, dumpStdErr, getBean, getBeans, getBeans, getContainedBeans, isAuto, isManaged, isUnmanaged, manage, removeBean, removeBeans, removeEventListener, setBeans, setStopTimeout, unmanage, updateBean, updateBean, updateBeans
-
Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
addLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop, toString
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.eclipse.jetty.util.component.LifeCycle
addLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
-
-
-
-
Field Detail
-
__DEFAULT_SERVLET
public static final java.lang.String __DEFAULT_SERVLET
Deprecated.- See Also:
- Constant Field Values
-
-
Method Detail
-
isDumpable
public boolean isDumpable(java.lang.Object o)
Deprecated.
-
dump
public void dump(java.lang.Appendable out, java.lang.String indent) throws java.io.IOException
Deprecated.Description copied from interface:Dumpable
Dump this object (and children) into an Appendable using the provided indent after any new lines. The indent should not be applied to the first object dumped.- Specified by:
dump
in interfaceDumpable
- Overrides:
dump
in classContainerLifeCycle
- Parameters:
out
- The appendable to dump toindent
- The indent to apply after any new lines.- Throws:
java.io.IOException
- if unable to write to Appendable
-
isEnsureDefaultServlet
public boolean isEnsureDefaultServlet()
Deprecated.- Returns:
- true if ServletHandler always has a default servlet, using
ServletHandler.Default404Servlet
if no other default servlet is configured.
-
setEnsureDefaultServlet
public void setEnsureDefaultServlet(boolean ensureDefaultServlet)
Deprecated.- Parameters:
ensureDefaultServlet
- true if ServletHandler always has a default servlet, usingServletHandler.Default404Servlet
if no other default servlet is configured.
-
getFilterMappings
@ManagedAttribute(value="filters", readonly=true) public FilterMapping[] getFilterMappings()
Deprecated.
-
getFilters
@ManagedAttribute(value="filters", readonly=true) public FilterHolder[] getFilters()
Deprecated.
-
getHolderEntry
@Deprecated public MappedResource<ServletHolder> getHolderEntry(java.lang.String target)
Deprecated.ServletHolder matching path.- Parameters:
target
- Path within _context or servlet name- Returns:
- PathMap Entries pathspec to ServletHolder
-
getServletContext
public ServletContext getServletContext()
Deprecated.
-
getServletContextHandler
public ServletContextHandler getServletContextHandler()
Deprecated.
-
getServletMappings
@ManagedAttribute(value="mappings of servlets", readonly=true) public ServletMapping[] getServletMappings()
Deprecated.
-
getServletMapping
public ServletMapping getServletMapping(java.lang.String pathSpec)
Deprecated.Get the ServletMapping matching the path- Parameters:
pathSpec
- the path spec- Returns:
- the servlet mapping for the path spec (or null if not found)
-
getServlets
@ManagedAttribute(value="servlets", readonly=true) public ServletHolder[] getServlets()
Deprecated.
-
getServlets
public java.util.List<ServletHolder> getServlets(java.lang.Class<?> clazz)
Deprecated.
-
getServlet
public ServletHolder getServlet(java.lang.String name)
Deprecated.
-
doScope
public void doScope(java.lang.String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, ServletException
Deprecated.Description copied from class:ScopedHandler
Scope the handlerDerived implementations should call
ScopedHandler.nextScope(String, Request, HttpServletRequest, HttpServletResponse)
- Overrides:
doScope
in classScopedHandler
- Parameters:
target
- The target of the request - either a URI or a name.baseRequest
- The original unwrapped request object.request
- The request either as theRequest
object or a wrapper of that request. The
method can be used access the Request object if required.HttpConnection.getCurrentConnection()
.getHttpChannel()
.getRequest()
response
- The response as theResponse
object or a wrapper of that request. The
method can be used access the Response object if required.HttpConnection.getCurrentConnection()
.getHttpChannel()
.getResponse()
- Throws:
java.io.IOException
- if unable to handle the request or response processingServletException
- if unable to handle the request or response due to underlying servlet issue
-
doHandle
public void doHandle(java.lang.String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, ServletException
Deprecated.Description copied from class:ScopedHandler
Do the handler work within the scope.Derived implementations should call
ScopedHandler.nextHandle(String, Request, HttpServletRequest, HttpServletResponse)
- Specified by:
doHandle
in classScopedHandler
- Parameters:
target
- The target of the request - either a URI or a name.baseRequest
- The original unwrapped request object.request
- The request either as theRequest
object or a wrapper of that request. The
method can be used access the Request object if required.HttpConnection.getCurrentConnection()
.getHttpChannel()
.getRequest()
response
- The response as theResponse
object or a wrapper of that request. The
method can be used access the Response object if required.HttpConnection.getCurrentConnection()
.getHttpChannel()
.getResponse()
- Throws:
java.io.IOException
- if unable to handle the request or response processingServletException
- if unable to handle the request or response due to underlying servlet issue
-
getMappedServlet
public MappedResource<ServletHolder> getMappedServlet(java.lang.String target)
Deprecated.ServletHolder matching path.- Parameters:
target
- Path within _context or servlet name- Returns:
- MappedResource to the ServletHolder. Named servlets have a null PathSpec
-
isAvailable
public boolean isAvailable()
Deprecated.- Returns:
- true if the handler is started and there are no unavailable servlets
-
setStartWithUnavailable
public void setStartWithUnavailable(boolean start)
Deprecated.- Parameters:
start
- True if this handler will start with unavailable servlets
-
isAllowDuplicateMappings
public boolean isAllowDuplicateMappings()
Deprecated.- Returns:
- the allowDuplicateMappings
-
setAllowDuplicateMappings
public void setAllowDuplicateMappings(boolean allowDuplicateMappings)
Deprecated.- Parameters:
allowDuplicateMappings
- the allowDuplicateMappings to set
-
isStartWithUnavailable
public boolean isStartWithUnavailable()
Deprecated.- Returns:
- True if this handler will start with unavailable servlets
-
initialize
public void initialize() throws java.lang.Exception
Deprecated.Initialize filters and load-on-startup servlets.- Throws:
java.lang.Exception
- if unable to initialize
-
isInitialized
public boolean isInitialized()
Deprecated.- Returns:
- true if initialized has been called, false otherwise
-
isFilterChainsCached
public boolean isFilterChainsCached()
Deprecated.- Returns:
- whether the filter chains are cached.
-
addListener
public void addListener(ListenerHolder listener)
Deprecated.Add a holder for a listener- Parameters:
listener
- the listener for the holder
-
getListeners
public ListenerHolder[] getListeners()
Deprecated.
-
setListeners
public void setListeners(ListenerHolder[] listeners)
Deprecated.
-
newListenerHolder
public ListenerHolder newListenerHolder(Source source)
Deprecated.
-
newServletHolder
public ServletHolder newServletHolder(Source source)
Deprecated.Add a new servlet holder- Parameters:
source
- the holder source- Returns:
- the servlet holder
-
addServletWithMapping
public ServletHolder addServletWithMapping(java.lang.String className, java.lang.String pathSpec)
Deprecated.Convenience method to add a servlet.- Parameters:
className
- the class namepathSpec
- the path spec- Returns:
- The servlet holder.
-
addServletWithMapping
public ServletHolder addServletWithMapping(java.lang.Class<? extends Servlet> servlet, java.lang.String pathSpec)
Deprecated.Convenience method to add a servlet.- Parameters:
servlet
- the servlet classpathSpec
- the path spec- Returns:
- The servlet holder.
-
addServletWithMapping
public void addServletWithMapping(ServletHolder servlet, java.lang.String pathSpec)
Deprecated.Convenience method to add a servlet.- Parameters:
servlet
- servlet holder to addpathSpec
- servlet mappings for the servletHolder
-
addServlet
public void addServlet(ServletHolder holder)
Deprecated.Convenience method to add a pre-constructed ServletHolder.- Parameters:
holder
- the servlet holder
-
addServletMapping
public void addServletMapping(ServletMapping mapping)
Deprecated.Convenience method to add a pre-constructed ServletMapping.- Parameters:
mapping
- the servlet mapping
-
setServletSecurity
public java.util.Set<java.lang.String> setServletSecurity(ServletRegistration.Dynamic registration, ServletSecurityElement servletSecurityElement)
Deprecated.
-
newFilterHolder
public FilterHolder newFilterHolder(Source source)
Deprecated.
-
getFilter
public FilterHolder getFilter(java.lang.String name)
Deprecated.
-
addFilterWithMapping
public FilterHolder addFilterWithMapping(java.lang.Class<? extends Filter> filter, java.lang.String pathSpec, java.util.EnumSet<DispatcherType> dispatches)
Deprecated.Convenience method to add a filter.- Parameters:
filter
- class of filter to createpathSpec
- filter mappings for filterdispatches
- seeFilterMapping.setDispatches(int)
- Returns:
- The filter holder.
-
addFilterWithMapping
public FilterHolder addFilterWithMapping(java.lang.String className, java.lang.String pathSpec, java.util.EnumSet<DispatcherType> dispatches)
Deprecated.Convenience method to add a filter.- Parameters:
className
- of filterpathSpec
- filter mappings for filterdispatches
- seeFilterMapping.setDispatches(int)
- Returns:
- The filter holder.
-
addFilterWithMapping
public void addFilterWithMapping(FilterHolder holder, java.lang.String pathSpec, java.util.EnumSet<DispatcherType> dispatches)
Deprecated.Convenience method to add a filter.- Parameters:
holder
- filter holder to addpathSpec
- filter mappings for filterdispatches
- seeFilterMapping.setDispatches(int)
-
addFilterWithMapping
public FilterHolder addFilterWithMapping(java.lang.Class<? extends Filter> filter, java.lang.String pathSpec, int dispatches)
Deprecated.Convenience method to add a filter.- Parameters:
filter
- class of filter to createpathSpec
- filter mappings for filterdispatches
- seeFilterMapping.setDispatches(int)
- Returns:
- The filter holder.
-
addFilterWithMapping
public FilterHolder addFilterWithMapping(java.lang.String className, java.lang.String pathSpec, int dispatches)
Deprecated.Convenience method to add a filter.- Parameters:
className
- of filterpathSpec
- filter mappings for filterdispatches
- seeFilterMapping.setDispatches(int)
- Returns:
- The filter holder.
-
addFilterWithMapping
public void addFilterWithMapping(FilterHolder holder, java.lang.String pathSpec, int dispatches)
Deprecated.Convenience method to add a filter.- Parameters:
holder
- filter holder to addpathSpec
- filter mappings for filterdispatches
- seeFilterMapping.setDispatches(int)
-
addFilter
@Deprecated public FilterHolder addFilter(java.lang.String className, java.lang.String pathSpec, java.util.EnumSet<DispatcherType> dispatches)
Deprecated.useaddFilterWithMapping(Class, String, EnumSet)
insteadConvenience method to add a filter with a mapping- Parameters:
className
- the filter class namepathSpec
- the path specdispatches
- the dispatcher types for this filter- Returns:
- the filter holder created
-
addFilter
public void addFilter(FilterHolder filter, FilterMapping filterMapping)
Deprecated.Convenience method to add a filter and mapping- Parameters:
filter
- the filter holderfilterMapping
- the filter mapping
-
addFilter
public void addFilter(FilterHolder filter)
Deprecated.Convenience method to add a preconstructed FilterHolder- Parameters:
filter
- the filter holder
-
addFilterMapping
public void addFilterMapping(FilterMapping mapping)
Deprecated.Convenience method to add a preconstructed FilterMapping- Parameters:
mapping
- the filter mapping
-
prependFilterMapping
public void prependFilterMapping(FilterMapping mapping)
Deprecated.Convenience method to add a preconstructed FilterMapping- Parameters:
mapping
- the filter mapping
-
setFilterChainsCached
public void setFilterChainsCached(boolean filterChainsCached)
Deprecated.- Parameters:
filterChainsCached
- The filterChainsCached to set.
-
setFilterMappings
public void setFilterMappings(FilterMapping[] filterMappings)
Deprecated.- Parameters:
filterMappings
- The filterMappings to set.
-
setFilters
public void setFilters(FilterHolder[] holders)
Deprecated.
-
setServletMappings
public void setServletMappings(ServletMapping[] servletMappings)
Deprecated.- Parameters:
servletMappings
- The servletMappings to set.
-
setServlets
public void setServlets(ServletHolder[] holders)
Deprecated.Set Servlets.- Parameters:
holders
- Array of servlets to define
-
getMaxFilterChainsCacheSize
public int getMaxFilterChainsCacheSize()
Deprecated.- Returns:
- The maximum entries in a filter chain cache.
-
setMaxFilterChainsCacheSize
public void setMaxFilterChainsCacheSize(int maxFilterChainsCacheSize)
Deprecated.Set the maximum filter chain cache size. Filter chains are cached ifisFilterChainsCached()
is true. If the max cache size is greater than zero, then the cache is flushed whenever it grows to be this size.- Parameters:
maxFilterChainsCacheSize
- the maximum number of entries in a filter chain cache.
-
-