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

public Class Context

extends ContextHandler
Class Inheritance
Known Direct Subclasses
org.mortbay.jetty.webapp.WebAppContext
Imports
javax.servlet.RequestDispatcher, .ServletContext, org.mortbay.jetty.HandlerContainer, org.mortbay.jetty.handler.ContextHandler, .ErrorHandler, org.mortbay.jetty.security.SecurityHandler, org.mortbay.log.Log, org.mortbay.util.URIUtil

Servlet Context. This conveniance extention 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 ServletContext.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public class

Field Summary

Modifier and TypeField and Description
protected SecurityHandler
protected ServletHandler
protected SessionHandler
public static final int
public static final int
public static final int
public static final int
Inherited from org.mortbay.jetty.handler.ContextHandler:
_scontextMANAGED_ATTRIBUTES

Constructor Summary

AccessConstructor and Description
public
public
Context(int options)

public
Context(HandlerContainer parent, String contextPath)

public
Context(HandlerContainer parent, String contextPath, int options)

public
Context(HandlerContainer parent, String contextPath, boolean sessions, boolean security)

public
Context(HandlerContainer parent, SessionHandler sessionHandler, SecurityHandler securityHandler, ServletHandler servletHandler, ErrorHandler errorHandler)

public
Context(HandlerContainer parent, String contextPath, SessionHandler sessionHandler, SecurityHandler securityHandler, ServletHandler servletHandler, ErrorHandler errorHandler)

Method Summary

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

conveniance method to add a filter

public FilterHolder
addFilter(Class<T> filterClass, String pathSpec, int dispatches)

conveniance method to add a filter

public FilterHolder
addFilter(String filterClass, String pathSpec, int dispatches)

conveniance method to add a filter

public ServletHolder
addServlet(String className, String pathSpec)

conveniance method to add a servlet.

public ServletHolder
addServlet(Class<T> servlet, String pathSpec)

conveniance method to add a servlet.

public void
addServlet(ServletHolder servlet, String pathSpec)

conveniance method to add a servlet.

public SecurityHandler

Returns:

Returns the securityHandler.
getSecurityHandler
()

public ServletHandler

Returns:

Returns the servletHandler.
getServletHandler
()

public SessionHandler

Returns:

Returns the sessionHandler.
getSessionHandler
()

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

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

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

protected void
Inherited from org.mortbay.jetty.handler.ContextHandler:
addEventListeneraddLocaleEncodingclearAttributesdoStartdoStopgetAllowNullPathInfogetAttributegetAttributeNamesgetAttributesgetBaseResourcegetClassLoadergetClassPathgetConnectorNamesgetContextPathgetCurrentContextgetDisplayNamegetErrorHandlergetEventListenersgetHostsgetInitParametergetInitParameterNamesgetInitParamsgetLocaleEncodinggetMaxFormContentSizegetMimeTypesgetResourcegetResourceBasegetResourcePathsgetServletContextgetVirtualHostsgetWelcomeFileshandleisCompactPathisProtectedTargetisShutdownloadClassremoveAttributesetAllowNullPathInfosetAttributesetAttributessetBaseResourcesetClassLoadersetCompactPathsetConnectorNamessetContextPathsetDisplayNamesetErrorHandlersetEventListenerssetHostssetInitParamssetMaxFormContentSizesetMimeTypessetResourceBasesetServersetShutdownsetVirtualHostssetWelcomeFilestoString

Field Detail

_securityHandlerback to summary
protected SecurityHandler _securityHandler
_servletHandlerback to summary
protected ServletHandler _servletHandler
_sessionHandlerback to summary
protected SessionHandler _sessionHandler
NO_SECURITYback to summary
public static final int NO_SECURITY
NO_SESSIONSback to summary
public static final int NO_SESSIONS
SECURITYback to summary
public static final int SECURITY
SESSIONSback to summary
public static final int SESSIONS

Constructor Detail

Contextback to summary
public Context()
Contextback to summary
public Context(int options)
Contextback to summary
public Context(HandlerContainer parent, String contextPath)
Contextback to summary
public Context(HandlerContainer parent, String contextPath, int options)
Contextback to summary
public Context(HandlerContainer parent, String contextPath, boolean sessions, boolean security)
Contextback to summary
public Context(HandlerContainer parent, SessionHandler sessionHandler, SecurityHandler securityHandler, ServletHandler servletHandler, ErrorHandler errorHandler)
Contextback to summary
public Context(HandlerContainer parent, String contextPath, SessionHandler sessionHandler, SecurityHandler securityHandler, ServletHandler servletHandler, ErrorHandler errorHandler)

Method Detail

addFilterback to summary
public void addFilter(FilterHolder holder, String pathSpec, int dispatches)

conveniance method to add a filter

addFilterback to summary
public FilterHolder addFilter(Class<T> filterClass, String pathSpec, int dispatches)

conveniance method to add a filter

addFilterback to summary
public FilterHolder addFilter(String filterClass, String pathSpec, int dispatches)

conveniance method to add a filter

addServletback to summary
public ServletHolder addServlet(String className, String pathSpec)

conveniance method to add a servlet.

addServletback to summary
public ServletHolder addServlet(Class<T> servlet, String pathSpec)

conveniance method to add a servlet.

addServletback to summary
public void addServlet(ServletHolder servlet, String pathSpec)

conveniance method to add a servlet.

getSecurityHandlerback to summary
public SecurityHandler getSecurityHandler()
Returns:SecurityHandler

Returns the securityHandler.

getServletHandlerback to summary
public ServletHandler getServletHandler()
Returns:ServletHandler

Returns the servletHandler.

getSessionHandlerback to summary
public SessionHandler getSessionHandler()
Returns:SessionHandler

Returns the sessionHandler.

setSecurityHandlerback to summary
public void setSecurityHandler(SecurityHandler securityHandler)
Parameters
securityHandler:SecurityHandler

The SecurityHandler to set on this context.

setServletHandlerback to summary
public void setServletHandler(ServletHandler servletHandler)
Parameters
servletHandler:ServletHandler

The servletHandler to set.

setSessionHandlerback to summary
public void setSessionHandler(SessionHandler sessionHandler)
Parameters
sessionHandler:SessionHandler

The sessionHandler to set.

startContextback to summary
protected void startContext() throws Exception

Overrides org.mortbay.jetty.handler.ContextHandler.startContext.

See Also
org.mortbay.jetty.handler.ContextHandler#startContext()
org.mortbay.jetty.servlet back to summary

public Class Context.SContext

extends SContext
Class Inheritance

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public RequestDispatcher
getNamedDispatcher(String
a String specifying the name of a servlet to wrap
name
)

Overrides org.mortbay.jetty.handler.ContextHandler.SContext.getNamedDispatcher.

Implements javax.servlet.ServletContext.getNamedDispatcher.

Returns a RequestDispatcher object that acts as a wrapper for the named servlet.
public RequestDispatcher
getRequestDispatcher(String
a String specifying the pathname to the resource
uriInContext
)

Overrides org.mortbay.jetty.handler.ContextHandler.SContext.getRequestDispatcher.

Implements javax.servlet.ServletContext.getRequestDispatcher.

Returns a RequestDispatcher object that acts as a wrapper for the resource located at the given path.
Inherited from org.mortbay.jetty.handler.ContextHandler.SContext:
getAttributegetAttributeNamesgetContextgetContextHandlergetContextPathgetInitParametergetInitParameterNamesgetMajorVersiongetMimeTypegetMinorVersiongetRealPathgetResourcegetResourceAsStreamgetResourcePathsgetServerInfogetServletgetServletContextNamegetServletNamesgetServletslogloglogremoveAttributesetAttributetoString

Constructor Detail

SContextback to summary
public SContext()

Method Detail

getNamedDispatcherback to summary
public RequestDispatcher getNamedDispatcher(String name)

Overrides org.mortbay.jetty.handler.ContextHandler.SContext.getNamedDispatcher.

Implements javax.servlet.ServletContext.getNamedDispatcher.

Doc from javax.servlet.ServletContext.getNamedDispatcher.

Returns a RequestDispatcher object that acts as a wrapper for the named servlet.

Servlets (and JSP pages also) may be given names via server administration or via a web application deployment descriptor. A servlet instance can determine its name using ServletConfig#getServletName.

This method returns null if the ServletContext cannot return a RequestDispatcher for any reason.

Parameters
name:String

a String specifying the name of a servlet to wrap

Returns:RequestDispatcher

a RequestDispatcher object that acts as a wrapper for the named servlet, or null if the ServletContext cannot return a RequestDispatcher

getRequestDispatcherback to summary
public RequestDispatcher getRequestDispatcher(String uriInContext)

Overrides org.mortbay.jetty.handler.ContextHandler.SContext.getRequestDispatcher.

Implements javax.servlet.ServletContext.getRequestDispatcher.

Doc from javax.servlet.ServletContext.getRequestDispatcher.

Returns a RequestDispatcher object that acts as a wrapper for the resource located at the given path. A RequestDispatcher object can be used to forward a request to the resource or to include the resource in a response. The resource can be dynamic or static.

The pathname must begin with a / and is interpreted as relative to the current context root. Use getContext to obtain a RequestDispatcher for resources in foreign contexts.

This method returns null if the ServletContext cannot return a RequestDispatcher.

Parameters
uriInContext:String

a String specifying the pathname to the resource

Returns:RequestDispatcher

a RequestDispatcher object that acts as a wrapper for the resource at the specified path, or null if the ServletContext cannot return a RequestDispatcher