## org.mortbay.jetty.servlet
Class Context

    java.lang.Object
      org.mortbay.component.AbstractLifeCycle
          org.mortbay.jetty.handler.AbstractHandler
              org.mortbay.jetty.handler.AbstractHandlerContainer
                  org.mortbay.jetty.handler.HandlerWrapper
                      org.mortbay.jetty.handler.ContextHandler
                          org.mortbay.jetty.servlet.Context

All Implemented Interfaces:
  LifeCycle, Handler, HandlerContainer, Server.Graceful, Attributes

Direct Known Subclasses:
  WebAppContext

    public class Context

extends ContextHandler

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 Class Summary
`class` `Context.SContext`

Nested classes/interfaces inherited from interface org.mortbay.component.LifeCycle
`LifeCycle.Listener`

Field Summary
`protected SecurityHandler` `_securityHandler`
`protected ServletHandler` `_servletHandler`
`protected SessionHandler` `_sessionHandler`
`static int` `NO_SECURITY`
`static int` `NO_SESSIONS`
`static int` `SECURITY`
`static int` `SESSIONS`

Fields inherited from class org.mortbay.jetty.handler.ContextHandler
`_scontext, MANAGED_ATTRIBUTES`

Fields inherited from class org.mortbay.jetty.handler.AbstractHandler
`_string`

Fields inherited from class org.mortbay.component.AbstractLifeCycle
`_listeners`

Fields inherited from interface org.mortbay.jetty.Handler
`ALL, DEFAULT, ERROR, FORWARD, INCLUDE, REQUEST`

Constructor Summary
`Context()`
`Context(HandlerContainer parent, SessionHandler sessionHandler, SecurityHandler securityHandler, ServletHandler servletHandler, ErrorHandler errorHandler)`
`Context(HandlerContainer parent, String contextPath)`
`Context(HandlerContainer parent, String contextPath, boolean sessions, boolean security)`
`Context(HandlerContainer parent, String contextPath, int options)`
`Context(HandlerContainer parent, String contextPath, SessionHandler sessionHandler, SecurityHandler securityHandler, ServletHandler servletHandler, ErrorHandler errorHandler)`
`Context(int options)`

Method Summary
`FilterHolder` `addFilter(Class filterClass, String pathSpec, int dispatches)` conveniance method to add a filter
`void` `addFilter(FilterHolder holder, String pathSpec, int dispatches)` conveniance method to add a filter
`FilterHolder` `addFilter(String filterClass, String pathSpec, int dispatches)` conveniance method to add a filter
`ServletHolder` `addServlet(Class servlet, String pathSpec)` conveniance method to add a servlet.
`void` `addServlet(ServletHolder servlet, String pathSpec)` conveniance method to add a servlet.
`ServletHolder` `addServlet(String className, String pathSpec)` conveniance method to add a servlet.
`SecurityHandler` `getSecurityHandler()`
`ServletHandler` `getServletHandler()`
`SessionHandler` `getSessionHandler()`
`void` `setSecurityHandler(SecurityHandler securityHandler)`
`void` `setServletHandler(ServletHandler servletHandler)`
`void` `setSessionHandler(SessionHandler sessionHandler)`
`protected void` `startContext()`

Methods inherited from class org.mortbay.jetty.handler.ContextHandler

`addEventListener, addLocaleEncoding, clearAttributes, doStart, doStop, getAllowNullPathInfo, getAttribute, getAttributeNames, getAttributes, getBaseResource, getClassLoader, getClassPath, getConnectorNames, getContextPath, getCurrentContext, getDisplayName, getErrorHandler, getEventListeners, getHosts, getInitParameter, getInitParameterNames, getInitParams, getLocaleEncoding, getMaxFormContentSize, getMimeTypes, getResource, getResourceBase, getResourcePaths, getServletContext, getVirtualHosts, getWelcomeFiles, handle, isCompactPath, isProtectedTarget, isShutdown, loadClass, removeAttribute, setAllowNullPathInfo, setAttribute, setAttributes, setBaseResource, setClassLoader, setCompactPath, setConnectorNames, setContextPath, setDisplayName, setErrorHandler, setEventListeners, setHosts, setInitParams, setMaxFormContentSize, setMimeTypes, setResourceBase, setServer, setShutdown, setVirtualHosts, setWelcomeFiles, toString`

Methods inherited from class org.mortbay.jetty.handler.HandlerWrapper
`addHandler, expandChildren, getHandler, removeHandler, setHandler`

Methods inherited from class org.mortbay.jetty.handler.AbstractHandlerContainer
`expandHandler, getChildHandlerByClass, getChildHandlers, getChildHandlersByClass`

Methods inherited from class org.mortbay.jetty.handler.AbstractHandler
`destroy, getServer`

Methods inherited from class org.mortbay.component.AbstractLifeCycle
`addLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Methods inherited from interface org.mortbay.component.LifeCycle
`addLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop`

Field Detail

### SESSIONS

    public static final int SESSIONS

See Also:
  Constant Field Values

### SECURITY

    public static final int SECURITY

See Also:
  Constant Field Values

### NO_SESSIONS

    public static final int NO_SESSIONS

See Also:
  Constant Field Values

### NO_SECURITY

    public static final int NO_SECURITY

See Also:
  Constant Field Values

### _securityHandler

    protected SecurityHandler _securityHandler

### _servletHandler

    protected ServletHandler _servletHandler

### _sessionHandler

    protected SessionHandler _sessionHandler

Constructor Detail

### Context

    public Context()

### Context

    public Context(int options)

### Context

    public Context(HandlerContainer parent,
                   String contextPath)

### Context

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

### Context

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

### Context

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

### Context

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

Method Detail

### startContext

    protected void startContext()
                         throws Exception

  Overrides:
    `startContext` in class `ContextHandler`
  Throws:
    `Exception`
  See Also:
    `ContextHandler.startContext()`

### getSecurityHandler

    public SecurityHandler getSecurityHandler()

  Returns:
    Returns the securityHandler.

### getServletHandler

    public ServletHandler getServletHandler()

  Returns:
    Returns the servletHandler.

### getSessionHandler

    public SessionHandler getSessionHandler()

  Returns:
    Returns the sessionHandler.

### addServlet

    public ServletHolder addServlet(String className,
                                    String pathSpec)

  conveniance method to add a servlet.

### addServlet

    public ServletHolder addServlet(Class servlet,
                                    String pathSpec)

  conveniance method to add a servlet.

### addServlet

    public void addServlet(ServletHolder servlet,
                           String pathSpec)

  conveniance method to add a servlet.

### addFilter

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

  conveniance method to add a filter

### addFilter

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

  conveniance method to add a filter

### addFilter

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

  conveniance method to add a filter

### setSessionHandler

    public void setSessionHandler(SessionHandler sessionHandler)

  Parameters:
    `sessionHandler` - The sessionHandler to set.

### setSecurityHandler

    public void setSecurityHandler(SecurityHandler securityHandler)

  Parameters:
    `securityHandler` - The `SecurityHandler` to set on this context.

### setServletHandler

    public void setServletHandler(ServletHandler servletHandler)

  Parameters:
    `servletHandler` - The servletHandler to set.

Copyright © 1995-2008 Mort Bay Consulting. All Rights Reserved.