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

public Class ContextHandler

extends HandlerWrapper
implements Attributes, Graceful, CompleteHandler
Class Inheritance
All Implemented Interfaces
org.mortbay.jetty.handler.CompleteHandler, org.mortbay.jetty.Server.Graceful, org.mortbay.util.Attributes
Known Direct Subclasses
org.mortbay.jetty.handler.MovedContextHandler, org.mortbay.jetty.servlet.Context
Imports
java.io.File, .IOException, .InputStream, java.net.MalformedURLException, .URL, .URLClassLoader, java.util.Arrays, .Collections, .EnumSet, .Enumeration, .EventListener, .HashMap, .HashSet, .Locale, .Map, .Set, javax.servlet.DispatcherType, .RequestDispatcher, .Servlet, .ServletContext, .ServletContextAttributeEvent, .ServletContextAttributeListener, .ServletContextEvent, .ServletContextListener, .ServletException, .ServletRequestAttributeListener, .ServletRequestEvent, .ServletRequestListener, javax.servlet.http.HttpServletRequest, .HttpServletResponse, org.mortbay.io.Buffer, org.mortbay.jetty.Dispatcher, .Handler, .HandlerContainer, .HttpConnection, .HttpException, .MimeTypes, .Request, .Server, org.mortbay.log.Log, .Logger, org.mortbay.resource.Resource, org.mortbay.util.Attributes, .AttributesMap, .LazyList, .Loader, .URIUtil

ContextHandler. This handler wraps a call to handle by setting the context and servlet path, plus setting the context classloader.

If the context init parameter "org.mortbay.jetty.servlet.ManagedAttributes" is set to a coma separated list of names, then they are treated as context attribute names, which if set as attributes are passed to the servers Container so that they may be managed with JMX.

Author
gregw

Nested and Inner Type Summary

Modifier and TypeClass and Description
public class

Field Summary

Modifier and TypeField and Description
private static ThreadLocal<ContextHandler.SContext>
private boolean
private boolean
private AttributesMap
private Resource
private ClassLoader
private boolean
private Set<String>
private Object
private AttributesMap
private Object
private String
private String
private ErrorHandler
private EventListener[]
private Map<String, String>
private Map<String, String>
private Logger
private Set<String>
private int
private MimeTypes
private Object
private Object
protected ContextHandler.SContext
private boolean
private String[]
private String[]
public static final String

Constructor Summary

AccessConstructor and Description
public
protected
public
ContextHandler(String contextPath)

public
ContextHandler(HandlerContainer parent, String contextPath)

Method Summary

Modifier and TypeMethod and Description
public void
addEventListener(EventListener listener)

Add a context event listeners.

public void
addLocaleEncoding(String locale, String encoding)

public void
public void
protected void
protected void
public boolean

Returns:

the allowNullPathInfo true if /context is not redirected to /context/
getAllowNullPathInfo
()

public Object
public Enumeration<E>
public Attributes

Returns:

Returns the attributes.
getAttributes
()

public Resource

Returns:

Returns the resourceBase.
getBaseResource
()

public ClassLoader

Returns:

Returns the classLoader.
getClassLoader
()

public String

Returns:

Returns the classLoader.
getClassPath
()

Make best effort to extract a file classpath from the context classloader

public String[]

Returns:

an array of connector names that this context will accept a request from.
getConnectorNames
()

public String

Returns:

Returns the _contextPath.
getContextPath
()

public static ContextHandler.SContext

Returns:

ServletContext implementation
getCurrentContext
()

Get the current ServletContext implementation.

public String
public ErrorHandler

Returns:

Returns the errorHandler.
getErrorHandler
()

public EventListener[]
public String[]
getHosts()

Deprecated
Get the hosts for the context.
public String
public Enumeration<E>
public Map<String, String>

Returns:

Returns the initParams.
getInitParams
()

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 Logger
public int
public MimeTypes

Returns:

Returns the mimeTypes.
getMimeTypes
()

public Resource
public String

Returns:

Returns the base resource as a string.
getResourceBase
()

public Set<String>
public ContextHandler.SContext
public String[]

Returns:

Array of virtual hosts that this context responds to. A null host name or empty array means any hostname is acceptable. Host names may be String representation of IP addresses. Host names may start with '*.' to wildcard one level of names.
getVirtualHosts
()

Get the virtual hosts for the context.

public String[]

Returns:

The names of the files which the server should consider to be welcome files in this context.
getWelcomeFiles
()

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
dispatch
)

Overrides org.mortbay.jetty.handler.HandlerWrapper.handle.

Implements org.mortbay.jetty.Handler.handle.

Handle a request.
public boolean

Returns:

True if alias checking is performed on resources.
isAliases
()

public boolean

Returns:

True if URLs are compacted to replace multiple '/'s with a single '/'
isCompactPath
()

protected boolean
isProtectedTarget(String target)

Check the target.

public boolean

Returns:

true if this context is accepting new requests
isShutdown
()

public synchronized Class<?>
loadClass(String className)

public Resource
newResource(URL url)

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

public Resource
newResource(String url)

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

private String
public void
public void
setAliases(boolean
alias checking performed on resources.
aliases
)

public void
setAllowNullPathInfo(boolean
true if /context is not redirected to /context/
allowNullPathInfo
)

public void
public void
setAttributes(Attributes
The attributes to set.
attributes
)

public void
setBaseResource(Resource
The resourceBase to set.
base
)

public void
setClassLoader(ClassLoader
The classLoader to set.
classLoader
)

public void
setCompactPath(boolean
True if URLs are compacted to replace multiple '/'s with a single '/'
compactPath
)

public void
setConnectorNames(String[]
If non null, an array of connector names that this context will accept a request from.
connectors
)

Set the names of accepted connectors.

public void
setContextPath(String
The _contextPath to set.
contextPath
)

public void
setDisplayName(String
The servletContextName to set.
servletContextName
)

public void
setErrorHandler(ErrorHandler
The errorHandler to set.
errorHandler
)

public void
setEventListeners(EventListener[] eventListeners)

Set the context event listeners.

public void
public void
setInitParams(Map<String, String>
The initParams to set.
initParams
)

public void
setLogger(Logger logger)

private void
public void
setMaxFormContentSize(int maxSize)

public void
setMimeTypes(MimeTypes
The mimeTypes to set.
mimeTypes
)

public void
setResourceBase(String
The base resource as a string.
resourceBase
)

public void
public void
setShutdown(boolean
true if this context is accepting new requests
shutdown
)

Implements org.mortbay.jetty.Server.Graceful.setShutdown.

Set shutdown status.
public void
setVirtualHosts(String[]
Array of virtual hosts that this context responds to. A null host name or null/empty array means any hostname is acceptable. Host names may be String representation of IP addresses. Host names may start with '*.' to wildcard one level of names.
vhosts
)

Set the virtual hosts for the context.

public void
protected void
public String
toString()

Overrides org.mortbay.jetty.handler.AbstractHandler.toString.

Returns a string representation of the object.
Inherited from org.mortbay.jetty.handler.HandlerWrapper:
addHandlerexpandChildrengetHandlerremoveHandlersetHandler