Top Description Inners Fields Constructors Methods
org.mortbay.jetty.servlet

public Class ServletHandler

extends AbstractHandler
Class Inheritance
Imports
java.io.IOException, java.util.ArrayList, .Arrays, .HashMap, .LinkedHashMap, .List, .Map, javax.servlet.Filter, .FilterChain, .RequestDispatcher, .Servlet, .ServletContext, .ServletException, .ServletRequest, .ServletRequestEvent, .ServletRequestListener, .ServletResponse, .UnavailableException, javax.servlet.http.HttpServletRequest, .HttpServletResponse, org.mortbay.io.RuntimeIOException, org.mortbay.jetty.EofException, .HttpConnection, .HttpException, .Request, .RetryRequest, .Server, org.mortbay.jetty.handler.AbstractHandler, .ContextHandler, org.mortbay.log.Log, org.mortbay.util.LazyList, .MultiException, .MultiMap, .URIUtil

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 when a full web application is not required. Specifically filters and request wrapping are not supported. Unless run as part of a Context or derivative, the initialize() method must be called manually after start().

Author
Greg Wilkins
See Also
org.mortbay.jetty.webapp.WebAppContext

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
private class
private class

Field Summary

Modifier and TypeField and Description
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
protected transient ServletHandler.MruCache[]
private ContextHandler
private boolean
private FilterMapping[]
private transient Map<K, V>
private transient MultiMap
private transient List<E>
private FilterHolder[]
private int
private ContextHandler.SContext
private ServletMapping[]
private transient Map<K, V>
private transient PathMap
private ServletHolder[]
private boolean
Inherited from org.mortbay.jetty.handler.AbstractHandler:
_string

Constructor Summary

AccessConstructor and Description
public
ServletHandler()

Constructor.

Method Summary

Modifier and TypeMethod and Description
public FilterHolder
addFilter(String className, String pathSpec, int dispatches)

Deprecated
Convenience method to add a filter with a mapping
public void
addFilter(FilterHolder filter, FilterMapping filterMapping)

convenience method to add a filter and mapping

public void
addFilter(FilterHolder filter)

Convenience method to add a preconstructed FilterHolder

public void
addFilterMapping(FilterMapping mapping)

Convenience method to add a preconstructed FilterMapping

public FilterHolder

Returns:

The filter holder.
addFilterWithMapping
(Class<T> filter, String pathSpec, int dispatches)

conveniance method to add a filter.

public FilterHolder

Returns:

The filter holder.
addFilterWithMapping
(String className, String pathSpec, int dispatches)

conveniance method to add a filter.

public void

Returns:

The filter holder.
addFilterWithMapping
(FilterHolder holder, String pathSpec, int dispatches)

conveniance method to add a filter.

public ServletHolder
addServlet(String className, String pathSpec)

Deprecated
Convenience method to add a servlet with a servlet mapping.
public void
addServlet(ServletHolder holder)

Convenience method to add a pre-constructed ServletHolder.

public void
addServletMapping(ServletMapping mapping)

Convenience method to add a pre-constructed ServletMapping.

public ServletHolder

Returns:

The servlet holder.
addServletWithMapping
(String className, String pathSpec)

conveniance method to add a servlet.

public ServletHolder

Returns:

The servlet holder.
addServletWithMapping
(Class<T> servlet, String pathSpec)

conveniance method to add a servlet.

public void

Returns:

The servlet holder.
addServletWithMapping
(ServletHolder servlet, String pathSpec)

conveniance method to add a servlet.

public Filter
customizeFilter(Filter filter)

Customize a Filter.

public Filter
public Servlet
customizeServlet(Servlet servlet)

Customize a servlet.

public Servlet
protected synchronized void
protected synchronized void
public Object

Returns:

Returns the contextLog.
getContextLog
()

public FilterHolder
private FilterChain
getFilterChain(int requestType, String pathInContext, ServletHolder servletHolder)

public FilterMapping[]

Returns:

Returns the filterMappings.
getFilterMappings
()

public FilterHolder[]

Returns:

Array of defined servlets
getFilters
()

Get Filters.

public PathMap.Entry

Returns:

PathMap Entries pathspec to ServletHolder
getHolderEntry
(String
Path within _context.
pathInContext
)

ServletHolder matching path.

public int

Returns:

The maximum entries in a filter chain cache.
getMaxFilterChainsCacheSize
()

public RequestDispatcher

Returns:

A dispatcher wrapping the resource at uriInContext, or null if the specified uri cannot be dispatched to.
getRequestDispatcher
(String uriInContext)

public ServletHolder
public ServletContext
public ServletMapping[]

Returns:

Returns the servletMappings.
getServletMappings
()

public ServletHolder[]

Returns:

Array of defined servlets
getServlets
()

Get Servlets.

public void
handle(String
The target of the request - either a URI or a name.
target
,
HttpServletRequest
The request either as the Request object or a wrapper of that request. The HttpConnection#getCurrentConnection() method can be used access the Request object if required.
request
,
HttpServletResponse
The response as the Response object or a wrapper of that request. The HttpConnection#getCurrentConnection() method can be used access the Response object if required.
response
,
int
The dispatch mode: REQUEST, FORWARD, INCLUDE, ERROR
type
)

Implements org.mortbay.jetty.Handler.handle.

Handle a request.
public void
initialize()

Initialize filters and load-on-startup servlets.

private void
public boolean

Returns:

true if the handler is started and there are no unavailable servlets
isAvailable
()

public boolean

Returns:

Returns the filterChainsCached.
isFilterChainsCached
()

public boolean

Returns:

Returns the initializeAtStart.
isInitializeAtStart
()

Deprecated
public boolean

Returns:

True if this handler will start with unavailable servlets
isStartWithUnavailable
()

public boolean

Returns:

whether there is a ServletHolder that matches this path
matchesPath
(String
Path within _context.
pathInContext
)

Whether there is a ServletHolder that matches this path

public FilterHolder
public FilterHolder
public ServletHolder
public ServletHolder
newServletHolder(Class<T> servlet)

protected void
public void
setFilterChainsCached(boolean
The filterChainsCached to set.
filterChainsCached
)

public void
setFilterMappings(FilterMapping[]
The filterMappings to set.
filterMappings
)

public synchronized void
public void
setInitializeAtStart(boolean
The initializeAtStart to set.
initializeAtStart
)

Deprecated
public void
setMaxFilterChainsCacheSize(int
the maximum number of entries in a filter chain cache.
maxFilterChainsCacheSize
)

Set the maximum filter chain cache size.

public void
public void
setServletMappings(ServletMapping[]
The servletMappings to set.
servletMappings
)

public synchronized void
setServlets(ServletHolder[]
Array of servletsto define
holders
)

Set Servlets.

public void
setStartWithUnavailable(boolean
True if this handler will start with unavailable servlets
start
)

protected synchronized void
protected synchronized void
Inherited from org.mortbay.jetty.handler.AbstractHandler:
destroygetServertoString