## org.mortbay.jetty.servlet
Class ServletHttpContext

    java.lang.Object
      |
      +--org.mortbay.http.HttpContext
            |
            +--org.mortbay.jetty.servlet.ServletHttpContext

All Implemented Interfaces:
  LifeCycle, java.io.Serializable

Direct Known Subclasses:
  WebApplicationContext

public class ServletHttpContext
extends HttpContext

ServletHttpContext. Extends HttpContext with conveniance methods for adding servlets. Enforces a single ServletHandler per context.

Version:
  $Id: ServletHttpContext.java,v 1.14 2003/06/27 19:21:53 hlavac Exp $
Author:
  Greg Wilkins (gregw)
See Also:
  Serialized Form

Nested Class Summary

Nested classes inherited from class org.mortbay.http.HttpContext
`HttpContext.ResourceMetaData`

Field Summary

Fields inherited from class org.mortbay.http.HttpContext
`__fileClassPathAttr`

Constructor Summary
`ServletHttpContext()` Constructor.

Method Summary
`ServletHolder` `addServlet(java.lang.String pathSpec, java.lang.String className)` Add a servlet to the context.
`ServletHolder` `addServlet(java.lang.String name, java.lang.String pathSpec, java.lang.String className)` Add a servlet to the context.
`boolean` `checkSecurityConstraints(java.lang.String pathInContext, HttpRequest request, HttpResponse response)`
`ServletContext` `getServletContext()`
`ServletHandler` `getServletHandler()` Get the context ServletHandler.
`void` `setDynamicServletPathSpec(java.lang.String pathSpecInContext)` Deprecated. Use org.mortbay.jetty.servlet.Invoker
`void` `stop()` Stop the context.
`java.lang.String` `toString()`

Methods inherited from class org.mortbay.http.HttpContext

`addHandler, addHandler, addPermission, addSecurityConstraint, addVirtualHost, addWelcomeFile, canonicalContextPathSpec, clearSecurityConstraints, destroy, flushCache, getAttribute, getAttributeNames, getAttributes, getAuthenticator, getBaseResource, getClassLoader, getClassPath, getContextPath, getEncodingByMimeType, getEncodingMap, getErrorPage, getFileClassPath, getHandler, getHandlerIndex, getHandlers, getHosts, getHttpConnection, getHttpContextName, getHttpServer, getInitParameter, getInitParameterNames, getMaxCachedFileSize, getMaxCacheSize, getMimeByExtension, getMimeMap, getParentClassLoader, getPermissions, getRealm, getRealmName, getRequestLog, getRequests, getRequestsActive, getRequestsActiveMax, getResource, getResourceBase, getResourceMetaData, getResponses1xx, getResponses2xx, getResponses3xx, getResponses4xx, getResponses5xx, getStatsOn, getStatsOnMs, getTempDirectory, getVirtualHosts, getWelcomeFile, getWelcomeFiles, handle, handle, isAuthConstrained, isClassLoaderJava2Compliant, isRedirectNullPath, isStarted, loadClass, log, removeAttribute, removeErrorPage, removeHandler, removeHandler, removeVirtualHost, removeWelcomeFile, setAttribute, setAttributes, setAuthenticator, setBaseResource, setClassLoader, setClassLoaderJava2Compliant, setClassPath, setClassPaths, setClassPaths, setContextPath, setEncodingMap, setErrorPage, setHandlers, setHosts, setInitParameter, setMaxCachedFileSize, setMaxCacheSize, setMimeMap, setMimeMapping, setParentClassLoader, setPermissions, setRealm, setRealmName, setRedirectNullPath, setRequestLog, setResourceBase, setStatsOn, setTempDirectory, setTypeEncoding, setVirtualHosts, setWelcomeFiles, start, statsReset, stop, toString`

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

Constructor Detail

### ServletHttpContext

    public ServletHttpContext()

  Constructor.

Method Detail

### getServletContext

    public ServletContext getServletContext()

  Returns:
    The ServletContext.

### getServletHandler

    public ServletHandler getServletHandler()

  Get the context ServletHandler. Conveniance method. If no ServletHandler exists, a new one is added to the context.

  Returns:
    ServletHandler

### addServlet

    public ServletHolder addServlet(java.lang.String pathSpec,
                                    java.lang.String className)
                             throws java.lang.ClassNotFoundException,
                                    java.lang.InstantiationException,
                                    java.lang.IllegalAccessException

  Add a servlet to the context. Conveniance method. If no ServletHandler is found in the context, a new one is added.

  Parameters:
    `pathSpec` - The pathspec within the context
    `className` - The classname of the servlet.
  Returns:
    The ServletHolder.
  Throws:
    `java.lang.ClassNotFoundException`
    `java.lang.InstantiationException`
    `java.lang.IllegalAccessException`

### addServlet

    public ServletHolder addServlet(java.lang.String name,
                                    java.lang.String pathSpec,
                                    java.lang.String className)
                             throws java.lang.ClassNotFoundException,
                                    java.lang.InstantiationException,
                                    java.lang.IllegalAccessException

  Add a servlet to the context. If no ServletHandler is found in the context, a new one is added.

  Parameters:
    `name` - The name of the servlet.
    `pathSpec` - The pathspec within the context
    `className` - The classname of the servlet.
  Returns:
    The ServletHolder.
  Throws:
    `java.lang.ClassNotFoundException`
    `java.lang.InstantiationException`
    `java.lang.IllegalAccessException`

### setDynamicServletPathSpec

    public void setDynamicServletPathSpec(java.lang.String pathSpecInContext)

  Deprecated. Use org.mortbay.jetty.servlet.Invoker

  Setup context for serving dynamic servlets.

### checkSecurityConstraints

    public boolean checkSecurityConstraints(java.lang.String pathInContext,
                                            HttpRequest request,
                                            HttpResponse response)
                                     throws HttpException,
                                            java.io.IOException

  Overrides:
    `checkSecurityConstraints` in class `HttpContext`
    `HttpException`
    `java.io.IOException`

### stop

    public void stop()
              throws java.lang.InterruptedException

  Description copied from class: `HttpContext`
  Stop the context.

  Specified by:
    `stop` in interface `LifeCycle`
  Overrides:
    `stop` in class `HttpContext`
  Throws:
    `java.lang.InterruptedException` - Stopping a lifecycle is rarely atomic and may be interrupted by another thread. If this happens InterruptedException is throw and the component will be in an indeterminant state and should probably be discarded.

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `HttpContext`

Copyright © 2000 Mortbay Consulting Pty. Ltd. All Rights Reserved.