Package org.eclipse.jetty.servlet
Class ServletHandler
- 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, the initialize()
method must be called manually after start().
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class org.eclipse.jetty.server.handler.AbstractHandler
AbstractHandler.ErrorDispatchHandlerNested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
AbstractLifeCycle.AbstractLifeCycleListenerNested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Container
Container.InheritedListener, Container.ListenerNested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable
Dumpable.DumpableContainerNested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle
LifeCycle.Listener -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddFilter(String className, String pathSpec, EnumSet<DispatcherType> dispatches) Deprecated.useaddFilterWithMapping(Class, String, EnumSet)insteadvoidaddFilter(FilterHolder filter) Deprecated.Convenience method to add a preconstructed FilterHoldervoidaddFilter(FilterHolder filter, FilterMapping filterMapping) Deprecated.Convenience method to add a filter and mappingvoidaddFilterMapping(FilterMapping mapping) Deprecated.Convenience method to add a preconstructed FilterMappingaddFilterWithMapping(Class<? extends Filter> filter, String pathSpec, int dispatches) Deprecated.Convenience method to add a filter.addFilterWithMapping(Class<? extends Filter> filter, String pathSpec, EnumSet<DispatcherType> dispatches) Deprecated.Convenience method to add a filter.addFilterWithMapping(String className, String pathSpec, int dispatches) Deprecated.Convenience method to add a filter.addFilterWithMapping(String className, String pathSpec, EnumSet<DispatcherType> dispatches) Deprecated.Convenience method to add a filter.voidaddFilterWithMapping(FilterHolder holder, String pathSpec, int dispatches) Deprecated.Convenience method to add a filter.voidaddFilterWithMapping(FilterHolder holder, String pathSpec, EnumSet<DispatcherType> dispatches) Deprecated.Convenience method to add a filter.voidaddListener(ListenerHolder listener) Deprecated.Add a holder for a listenervoidaddServlet(ServletHolder holder) Deprecated.Convenience method to add a pre-constructed ServletHolder.voidaddServletMapping(ServletMapping mapping) Deprecated.Convenience method to add a pre-constructed ServletMapping.addServletWithMapping(Class<? extends Servlet> servlet, String pathSpec) Deprecated.Convenience method to add a servlet.addServletWithMapping(String className, String pathSpec) Deprecated.Convenience method to add a servlet.voidaddServletWithMapping(ServletHolder servlet, String pathSpec) Deprecated.Convenience method to add a servlet.voiddoHandle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) Deprecated.Do the handler work within the scope.voiddoScope(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) Deprecated.Scope the handlervoiddump(Appendable out, String indent) Deprecated.Dump this object (and children) into an Appendable using the provided indent after any new lines.Deprecated.Deprecated.Deprecated.getHolderEntry(String target) Deprecated.UsegetMatchedServlet(String)insteadDeprecated.getMappedServlet(String target) Deprecated.usegetMatchedServlet(String)insteadgetMatchedServlet(String target) Deprecated.ServletHolder matching target path.intDeprecated.getServlet(String name) Deprecated.Deprecated.Deprecated.getServletMapping(String pathSpec) Deprecated.Get the ServletMapping matching the pathDeprecated.Deprecated.getServlets(Class<?> clazz) Deprecated.voidDeprecated.Initialize filters and load-on-startup servlets.booleanDeprecated.booleanDeprecated.booleanisDumpable(Object o) Deprecated.booleanDeprecated.booleanDeprecated.booleanDeprecated.booleanDeprecated.newFilterHolder(Source source) Deprecated.newListenerHolder(Source source) Deprecated.newServletHolder(Source source) Deprecated.Add a new servlet holdervoidprependFilterMapping(FilterMapping mapping) Deprecated.Convenience method to add a preconstructed FilterMappingvoidsetAllowDuplicateMappings(boolean allowDuplicateMappings) Deprecated.voidsetEnsureDefaultServlet(boolean ensureDefaultServlet) Deprecated.voidsetFilterChainsCached(boolean filterChainsCached) Deprecated.voidsetFilterMappings(FilterMapping[] filterMappings) Deprecated.voidsetFilters(FilterHolder[] holders) Deprecated.voidsetListeners(ListenerHolder[] listeners) Deprecated.voidsetMaxFilterChainsCacheSize(int maxFilterChainsCacheSize) Deprecated.Set the maximum filter chain cache size.voidsetServletMappings(ServletMapping[] servletMappings) Deprecated.voidsetServlets(ServletHolder[] holders) Deprecated.Set Servlets.setServletSecurity(ServletRegistration.Dynamic registration, ServletSecurityElement servletSecurityElement) Deprecated.voidsetStartWithUnavailable(boolean start) Deprecated.Methods inherited from class org.eclipse.jetty.server.handler.ScopedHandler
handle, nextHandle, nextScopeMethods inherited from class org.eclipse.jetty.server.handler.HandlerWrapper
destroy, getHandler, getHandlers, insertHandler, setHandlerMethods inherited from class org.eclipse.jetty.server.handler.AbstractHandlerContainer
findContainerOf, getChildHandlerByClass, getChildHandlers, getChildHandlersByClass, setServerMethods inherited from class org.eclipse.jetty.server.handler.AbstractHandler
getServerMethods 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, updateBeansMethods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
addLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop, toStringMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.eclipse.jetty.util.component.LifeCycle
addLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
-
Field Details
-
__DEFAULT_SERVLET
Deprecated.- See Also:
-
-
Constructor Details
-
ServletHandler
public ServletHandler()Deprecated.Constructor.
-
-
Method Details
-
isDumpable
Deprecated. -
dump
Deprecated.Description copied from interface:DumpableDump 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:
dumpin interfaceDumpable- Overrides:
dumpin classContainerLifeCycle- Parameters:
out- The appendable to dump toindent- The indent to apply after any new lines.- Throws:
IOException- if unable to write to Appendable
-
isEnsureDefaultServlet
public boolean isEnsureDefaultServlet()Deprecated.- Returns:
- true if ServletHandler always has a default servlet, using
ServletHandler.Default404Servletif no other default servlet is configured.
-
setEnsureDefaultServlet
public void setEnsureDefaultServlet(boolean ensureDefaultServlet) Deprecated.- Parameters:
ensureDefaultServlet- true if ServletHandler always has a default servlet, usingServletHandler.Default404Servletif no other default servlet is configured.
-
getFilterMappings
Deprecated. -
getFilters
Deprecated. -
getHolderEntry
Deprecated.UsegetMatchedServlet(String)insteadServletHolder matching path.- Parameters:
target- Path within _context or servlet name- Returns:
- PathMap Entries pathspec to ServletHolder
-
getServletContext
Deprecated. -
getServletContextHandler
Deprecated. -
getServletMappings
@ManagedAttribute(value="mappings of servlets", readonly=true) public ServletMapping[] getServletMappings()Deprecated. -
getServletMapping
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
Deprecated. -
getServlets
Deprecated. -
getServlet
Deprecated. -
doScope
public void doScope(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException Deprecated.Description copied from class:ScopedHandlerScope the handlerDerived implementations should call
ScopedHandler.nextScope(String, Request, HttpServletRequest, HttpServletResponse)- Overrides:
doScopein 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 theRequestobject or a wrapper of that request. Themethod can be used access the Request object if required.HttpConnection.getCurrentConnection().getHttpChannel().getRequest()response- The response as theResponseobject or a wrapper of that request. Themethod can be used access the Response object if required.HttpConnection.getCurrentConnection().getHttpChannel().getResponse()- Throws:
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(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException Deprecated.Description copied from class:ScopedHandlerDo the handler work within the scope.Derived implementations should call
ScopedHandler.nextHandle(String, Request, HttpServletRequest, HttpServletResponse)- Specified by:
doHandlein 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 theRequestobject or a wrapper of that request. Themethod can be used access the Request object if required.HttpConnection.getCurrentConnection().getHttpChannel().getRequest()response- The response as theResponseobject or a wrapper of that request. Themethod can be used access the Response object if required.HttpConnection.getCurrentConnection().getHttpChannel().getResponse()- Throws:
IOException- if unable to handle the request or response processingServletException- if unable to handle the request or response due to underlying servlet issue
-
getMatchedServlet
Deprecated.ServletHolder matching target path.- Parameters:
target- Path within _context or servlet name- Returns:
- MatchedResource, pointing to the
MappedResourcefor theServletHolder, and also the pathspec specific name/info sections for the match. Named servlets have a null PathSpec andMatchedResource.
-
getMappedServlet
Deprecated.usegetMatchedServlet(String)insteadServletHolder 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
-
isAllowDuplicateMappings
public boolean isAllowDuplicateMappings()Deprecated.- Returns:
- the allowDuplicateMappings
-
setAllowDuplicateMappings
public void setAllowDuplicateMappings(boolean allowDuplicateMappings) Deprecated.- Parameters:
allowDuplicateMappings- the allowDuplicateMappings to set
-
initialize
Deprecated.Initialize filters and load-on-startup servlets.- Throws:
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
Deprecated.Add a holder for a listener- Parameters:
listener- the listener for the holder
-
getListeners
Deprecated. -
setListeners
Deprecated. -
newListenerHolder
Deprecated. -
newServletHolder
Deprecated.Add a new servlet holder- Parameters:
source- the holder source- Returns:
- the servlet holder
-
addServletWithMapping
Deprecated.Convenience method to add a servlet.- Parameters:
className- the class namepathSpec- the path spec- Returns:
- The servlet holder.
-
addServletWithMapping
Deprecated.Convenience method to add a servlet.- Parameters:
servlet- the servlet classpathSpec- the path spec- Returns:
- The servlet holder.
-
addServletWithMapping
Deprecated.Convenience method to add a servlet.- Parameters:
servlet- servlet holder to addpathSpec- servlet mappings for the servletHolder
-
addServlet
Deprecated.Convenience method to add a pre-constructed ServletHolder.- Parameters:
holder- the servlet holder
-
addServletMapping
Deprecated.Convenience method to add a pre-constructed ServletMapping.- Parameters:
mapping- the servlet mapping
-
setServletSecurity
public Set<String> setServletSecurity(ServletRegistration.Dynamic registration, ServletSecurityElement servletSecurityElement) Deprecated. -
newFilterHolder
Deprecated. -
getFilter
Deprecated. -
addFilterWithMapping
public FilterHolder addFilterWithMapping(Class<? extends Filter> filter, String pathSpec, 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(String className, String pathSpec, 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, String pathSpec, 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(Class<? extends Filter> filter, 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
Deprecated.Convenience method to add a filter.- Parameters:
className- of filterpathSpec- filter mappings for filterdispatches- seeFilterMapping.setDispatches(int)- Returns:
- The filter holder.
-
addFilterWithMapping
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(String className, String pathSpec, 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
Deprecated.Convenience method to add a filter and mapping- Parameters:
filter- the filter holderfilterMapping- the filter mapping
-
addFilter
Deprecated.Convenience method to add a preconstructed FilterHolder- Parameters:
filter- the filter holder
-
addFilterMapping
Deprecated.Convenience method to add a preconstructed FilterMapping- Parameters:
mapping- the filter mapping
-
prependFilterMapping
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
Deprecated.- Parameters:
filterMappings- The filterMappings to set.
-
setFilters
Deprecated. -
setServletMappings
Deprecated.- Parameters:
servletMappings- The servletMappings to set.
-
setServlets
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.
-