Servlet HttpHandler.
This handler maps requests to servlets that implement the
javax.servlet.http.HttpServlet API.
This handler does not implement the full J2EE features and is intended to
be used when a full web application is not required. Specifically filters
and request wrapping are not supported.
If a SessionManager is not added to the handler before it is
initialized, then a HashSessionManager with a standard
java.util.Random generator is created.
__DEFAULT_SERVLET
public static final String __DEFAULT_SERVLET
__J_S_CONTEXT_TEMPDIR
public static final String __J_S_CONTEXT_TEMPDIR
__J_S_ERROR_EXCEPTION
public static final String __J_S_ERROR_EXCEPTION
__J_S_ERROR_EXCEPTION_TYPE
public static final String __J_S_ERROR_EXCEPTION_TYPE
__J_S_ERROR_MESSAGE
public static final String __J_S_ERROR_MESSAGE
__J_S_ERROR_REQUEST_URI
public static final String __J_S_ERROR_REQUEST_URI
__J_S_ERROR_SERVLET_NAME
public static final String __J_S_ERROR_SERVLET_NAME
__J_S_ERROR_STATUS_CODE
public static final String __J_S_ERROR_STATUS_CODE
_attributes
protected Map _attributes
_context
protected org.mortbay.jetty.servlet.ServletHandler.Context _context
_contextLog
protected Log _contextLog
_formErrorPage
protected String _formErrorPage
_formLoginPage
protected String _formLoginPage
_loader
protected ClassLoader _loader
_nameMap
protected Map _nameMap
_servletMap
protected PathMap _servletMap
addServlet
public ServletHolder addServlet(String pathSpec,
String servletClass)
Add a servlet instance to this handler and map it to a pathspec.
pathSpec
- The pathmappingservletClass
- The class of the servlet
- The created ServletHolder
addServlet
public ServletHolder addServlet(String name,
String pathSpec,
String servletClass)
Add a servlet.
name
- The servlet name.pathSpec
- A path specification to map this servlet to.servletClass
- The class name of the servlet.
- The ServletHolder for the servlet.
addServlet
public ServletHolder addServlet(String name,
String pathSpec,
String servletClass,
String forcedPath)
Add a servlet.
name
- The servlet name.pathSpec
- A path specification to map this servlet to.servletClass
- The class name of the servlet.forcedPath
- If non null, the request attribute
javax.servlet.include.servlet_path will be set to this path before
service is called.
- The ServletHolder for the servlet.
addServletHolder
public void addServletHolder(ServletHolder holder)
Register an existing ServletHolder with this handler.
holder
- the ServletHolder to register.
destroy
public void destroy()
Destroy a stopped server.
Remove all components and send notifications to all event
listeners. The HttpServer must be stopped before it can be destroyed.
- destroy in interface Container
dispatch
protected void dispatch(String pathInContext,
HttpServletRequest request,
HttpServletResponse response,
ServletHolder servletHolder,
int type)
throws ServletException,
UnavailableException,
IOException
Dispatch to a servletHolder.
This method may be specialized to insert extra handling in the
dispatch of a request to a specific servlet. This is used by
WebApplicatonHandler to implement dispatched filters.
The default implementation simply calls
ServletHolder.handle(request,response)
pathInContext
- The path used to select the servlet holder.request
- response
- servletHolder
- type
- the type of dispatch as defined in the Dispatcher class.
doStart
protected void doStart()
throws Exception
Do start operations.
This abstract method is called by start
to perform the actual start operations.
- doStart in interface Container
doStop
protected void doStop()
throws Exception
Do stop operations.
This abstract method is called by stop
to perform the actual stop operations.
- doStop in interface Container
finalize
protected void finalize()
throws Throwable
formAuthInit
public void formAuthInit(String formLoginPage,
String formErrorPage)
getClassLoader
public ClassLoader getClassLoader()
getContextAttribute
protected Object getContextAttribute(String name)
Get context attribute.
Tries ServletHandler attributes and then delegated to HttpContext.
getContextAttributeNames
protected Enumeration getContextAttributeNames()
Get context attribute names.
Combines ServletHandler and HttpContext attributes.
getHolderEntry
public Map.Entry getHolderEntry(String pathInContext)
ServletHolder matching path.
pathInContext
- Path within context.
- PathMap Entries pathspec to ServletHolder
getHttpSession
public HttpSession getHttpSession(String id)
getName
public String getName()
Get the name of the handler.
- getName in interface HttpHandler
- The name of the handler used for logging and reporting.
getNamedDispatcher
public RequestDispatcher getNamedDispatcher(String name)
Get Named dispatcher.
name
- The name of the servlet. If null or empty string, the
containers default servlet is returned.
- Request dispatcher for the named servlet.
getRealPath
public String getRealPath(String path)
getRequestDispatcher
public RequestDispatcher getRequestDispatcher(String uriInContext)
getResource
public URL getResource(String uriInContext)
throws MalformedURLException
Get a Resource.
If no resource is found, resource aliases are tried.
getResourceAsStream
public InputStream getResourceAsStream(String uriInContext)
getResourcePaths
public Set getResourcePaths(String uriInContext)
getServletHolder
public ServletHolder getServletHolder(String name)
getServletMap
public PathMap getServletMap()
getServlets
public ServletHolder[] getServlets()
Get Servlets.
- Array of defined servlets
handle
public void handle(String pathInContext,
String pathParams,
HttpRequest httpRequest,
HttpResponse httpResponse)
throws IOException
Handle request.
- handle in interface HttpHandler
pathInContext
- pathParams
- httpRequest
- httpResponse
-
initializeServlets
public void initializeServlets()
throws Exception
Initialize load-on-startup servlets.
Called automatically from start if autoInitializeServlet is true.
isAutoInitializeServlets
public boolean isAutoInitializeServlets()
isUsingCookies
public boolean isUsingCookies()
mapPathToServlet
public ServletHolder mapPathToServlet(String pathSpec,
String servletName)
Map a servlet to a pathSpec
pathSpec
- The pathspec to mapservletName
- The name of the servlet, which must have already been added.
- The servlet holder of the mapped servlet.
newServletHolder
public ServletHolder newServletHolder(String name,
String servletClass)
newServletHolder
public ServletHolder newServletHolder(String name,
String servletClass,
String forcedPath)
removeContextAttribute
protected void removeContextAttribute(String name)
setAutoInitializeServlets
public void setAutoInitializeServlets(boolean b)
setContextAttribute
protected void setContextAttribute(String name,
Object value)
setDynamicInitParams
public void setDynamicInitParams(Map initParams)
Use org.mortbay.jetty.servlet.Invoker
Set dynamic servlet initial parameters.
setDynamicServletPathSpec
public void setDynamicServletPathSpec(String dynamicServletPathSpec)
Use org.mortbay.jetty.servlet.Invoker
Set the dynamic servlet path.
setName
public void setName(String name)
setServeDynamicSystemServlets
public void setServeDynamicSystemServlets(boolean b)
Use org.mortbay.jetty.servlet.Invoker
Set serving dynamic system servlets.
setSessionInactiveInterval
public void setSessionInactiveInterval(int seconds)
Set the session timeout interval in seconds.
seconds
- the length of the session timeout interval in seconds.
setUsingCookies
public void setUsingCookies(boolean uc)
uc
- If true, cookies are used for sessions