org.mortbay.jetty.servlet

Class ServletHttpContext

Implemented Interfaces:
EventProvider, HttpHandler, LifeCycle, Serializable
Known Direct 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.27 2005/04/13 16:30:47 janb Exp $
Author:
Greg Wilkins (gregw)

Field Summary

Fields inherited from class org.mortbay.http.HttpContext

__ErrorHandler, __fileClassPathAttr

Constructor Summary

ServletHttpContext()
Constructor.

Method Summary

void
addLocaleEncoding(String locale, String encoding)
ServletHolder
addServlet(String pathSpec, String className)
Add a servlet to the context.
ServletHolder
addServlet(String name, String pathSpec, String className)
Add a servlet to the context.
boolean
checkSecurityConstraints(String pathInContext, HttpRequest request, HttpResponse response)
void
destroy()
protected void
doStop()
Object
enterContextScope(HttpRequest request, HttpResponse response)
String
getLocaleEncoding(Locale locale)
Get the character encoding for a locale.
ServletContext
getServletContext()
ServletHandler
getServletHandler()
Get the context ServletHandler.
protected boolean
jSecurityCheck(String pathInContext, HttpRequest request, HttpResponse response)
void
sendError(HttpResponse response, int code, String msg)
String
toString()

Methods inherited from class org.mortbay.http.HttpContext

addClassPath, addClassPaths, addHandler, addHandler, addPermission, addSecurityConstraint, addVirtualHost, addWelcomeFile, canonicalContextPathSpec, checkSecurityConstraints, clearSecurityConstraints, destroy, doStart, doStop, enterContextScope, flushCache, getAttribute, getAttributeNames, getAttributes, getAuthenticator, getBaseResource, getClassLoader, getClassPath, getContextPath, getEncodingByMimeType, getEncodingMap, getFileClassPath, getHandler, getHandlerIndex, getHandlers, getHosts, getHttpConnection, getHttpContext, getHttpContextName, getHttpServer, getInitParameter, getInitParameterNames, getMaxCacheSize, getMaxCachedFileSize, getMimeByExtension, getMimeMap, getName, getParentClassLoader, getPermissions, getRealm, getRealmName, getRequestLog, getRequests, getRequestsActive, getRequestsActiveMax, getResource, getResourceBase, getResourceMetaData, getResponses1xx, getResponses2xx, getResponses3xx, getResponses4xx, getResponses5xx, getServerClasses, getStatsOn, getStatsOnMs, getStopGracefully, getSystemClasses, getTempDirectory, getVirtualHosts, getWelcomeFile, getWelcomeFiles, handle, handle, initClassLoader, initialize, isClassLoaderJava2Compliant, isRedirectNullPath, leaveContextScope, loadClass, log, removeAttribute, removeHandler, removeHandler, removeVirtualHost, removeWelcomeFile, sendContextError, sendError, setAttribute, setAttributes, setAuthenticator, setBaseResource, setClassLoader, setClassLoaderJava2Compliant, setClassPath, setContextPath, setEncodingMap, setHandlers, setHosts, setHttpContextName, setInitParameter, setMaxCacheSize, setMaxCachedFileSize, setMimeMap, setMimeMapping, setParentClassLoader, setPermissions, setRealm, setRealmName, setRedirectNullPath, setRequestLog, setResourceBase, setServerClasses, setStatsOn, setStopGracefully, setSystemClasses, setTempDirectory, setTypeEncoding, setVirtualHosts, setWelcomeFiles, startHandlers, statsReset, stop, toString, toString

Methods inherited from class org.mortbay.util.Container

addComponent, addEventListener, destroy, doStart, doStop, getComponents, isStarted, isStarting, isStopping, removeComponent, removeEventListener, start, stop

Constructor Details

ServletHttpContext

public ServletHttpContext()
Constructor.

Method Details

addLocaleEncoding

public void addLocaleEncoding(String locale,
                              String encoding)

addServlet

public ServletHolder addServlet(String pathSpec,
                                String className)
            throws ClassNotFoundException,
                   InstantiationException,
                   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.

addServlet

public ServletHolder addServlet(String name,
                                String pathSpec,
                                String className)
            throws ClassNotFoundException,
                   InstantiationException,
                   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.

checkSecurityConstraints

public boolean checkSecurityConstraints(String pathInContext,
                                        HttpRequest request,
                                        HttpResponse response)
            throws HttpException,
                   IOException
Overrides:
checkSecurityConstraints in interface HttpContext

destroy

public void destroy()
Overrides:
destroy in interface HttpContext

doStop

protected void doStop()
            throws Exception
Overrides:
doStop in interface HttpContext

enterContextScope

public Object enterContextScope(HttpRequest request,
                                HttpResponse response)
Overrides:
enterContextScope in interface HttpContext

getLocaleEncoding

public String getLocaleEncoding(Locale locale)
Get the character encoding for a locale. The full locale name is first looked up in the map of encodings. If no encoding is found, then the locale language is looked up.
Parameters:
locale - a Locale value
Returns:
a String representing the character encoding for the locale or null if none found.

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

jSecurityCheck

protected boolean jSecurityCheck(String pathInContext,
                                 HttpRequest request,
                                 HttpResponse response)
            throws IOException

sendError

public void sendError(HttpResponse response,
                      int code,
                      String msg)
            throws IOException
Overrides:
sendError in interface HttpContext

toString

public String toString()
Overrides:
toString in interface HttpContext

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