|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.openqa.jetty.util.Container
org.openqa.jetty.jetty.servlet.ServletHandler
public class ServletHandler
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.
WebApplicationHandler
,
Serialized FormField Summary | |
---|---|
static java.lang.String |
__DEFAULT_SERVLET
|
static java.lang.String |
__J_S_CONTEXT_TEMPDIR
|
static java.lang.String |
__J_S_ERROR_EXCEPTION
|
static java.lang.String |
__J_S_ERROR_EXCEPTION_TYPE
|
static java.lang.String |
__J_S_ERROR_MESSAGE
|
static java.lang.String |
__J_S_ERROR_REQUEST_URI
|
static java.lang.String |
__J_S_ERROR_SERVLET_NAME
|
static java.lang.String |
__J_S_ERROR_STATUS_CODE
|
protected java.util.Map |
_attributes
|
protected org.openqa.jetty.jetty.servlet.ServletHandler.Context |
_context
|
protected org.apache.commons.logging.Log |
_contextLog
|
protected java.lang.String |
_formErrorPage
|
protected java.lang.String |
_formLoginPage
|
protected HttpContext |
_httpContext
|
protected java.lang.ClassLoader |
_loader
|
protected java.util.Map |
_nameMap
|
protected PathMap |
_servletMap
|
protected SessionManager |
_sessionManager
|
Constructor Summary | |
---|---|
ServletHandler()
Constructor. |
Method Summary | |
---|---|
ServletHolder |
addServlet(java.lang.String pathSpec,
java.lang.String servletClass)
Add a servlet instance to this handler and map it to a pathspec. |
ServletHolder |
addServlet(java.lang.String name,
java.lang.String pathSpec,
java.lang.String servletClass)
Add a servlet. |
ServletHolder |
addServlet(java.lang.String name,
java.lang.String pathSpec,
java.lang.String servletClass,
java.lang.String forcedPath)
Add a servlet. |
void |
addServletHolder(ServletHolder holder)
Register an existing ServletHolder with this handler. |
void |
destroy()
Destroy a stopped server. |
protected void |
dispatch(java.lang.String pathInContext,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
ServletHolder servletHolder,
int type)
Dispatch to a servletHolder. |
protected void |
doStart()
Do start operations. |
protected void |
doStop()
Do stop operations. |
protected void |
finalize()
|
void |
formAuthInit(java.lang.String formLoginPage,
java.lang.String formErrorPage)
|
java.lang.ClassLoader |
getClassLoader()
|
protected java.lang.Object |
getContextAttribute(java.lang.String name)
Get context attribute. |
protected java.util.Enumeration |
getContextAttributeNames()
Get context attribute names. |
java.lang.String |
getErrorPage(int status,
ServletHttpRequest request)
|
java.util.Map.Entry |
getHolderEntry(java.lang.String pathInContext)
ServletHolder matching path. |
HttpContext |
getHttpContext()
|
javax.servlet.http.HttpSession |
getHttpSession(java.lang.String id)
|
java.lang.String |
getName()
Get the name of the handler. |
javax.servlet.RequestDispatcher |
getNamedDispatcher(java.lang.String name)
Get Named dispatcher. |
java.lang.String |
getRealPath(java.lang.String path)
|
javax.servlet.RequestDispatcher |
getRequestDispatcher(java.lang.String uriInContext)
|
java.net.URL |
getResource(java.lang.String uriInContext)
Get a Resource. |
java.io.InputStream |
getResourceAsStream(java.lang.String uriInContext)
|
java.util.Set |
getResourcePaths(java.lang.String uriInContext)
|
javax.servlet.ServletContext |
getServletContext()
|
ServletHolder |
getServletHolder(java.lang.String name)
|
PathMap |
getServletMap()
|
ServletHolder[] |
getServlets()
Get Servlets. |
SessionManager |
getSessionManager()
|
void |
handle(java.lang.String pathInContext,
java.lang.String pathParams,
HttpRequest httpRequest,
HttpResponse httpResponse)
Handle request. |
protected void |
handleOptions(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
|
void |
handleTrace(HttpRequest request,
HttpResponse response)
|
protected void |
handleTrace(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
|
void |
initialize(HttpContext context)
|
void |
initializeServlets()
Initialize load-on-startup servlets. |
boolean |
isAutoInitializeServlets()
|
boolean |
isUsingCookies()
|
ServletHolder |
mapPathToServlet(java.lang.String pathSpec,
java.lang.String servletName)
Map a servlet to a pathSpec |
javax.servlet.http.HttpSession |
newHttpSession(javax.servlet.http.HttpServletRequest request)
|
ServletHolder |
newServletHolder(java.lang.String name,
java.lang.String servletClass)
|
ServletHolder |
newServletHolder(java.lang.String name,
java.lang.String servletClass,
java.lang.String forcedPath)
|
protected void |
notFound(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
|
protected void |
removeContextAttribute(java.lang.String name)
|
void |
setAutoInitializeServlets(boolean b)
|
protected void |
setContextAttribute(java.lang.String name,
java.lang.Object value)
|
void |
setDynamicInitParams(java.util.Map initParams)
Deprecated. Use org.openqa.jetty.jetty.servlet.Invoker |
void |
setDynamicServletPathSpec(java.lang.String dynamicServletPathSpec)
Deprecated. Use org.openqa.jetty.jetty.servlet.Invoker |
void |
setName(java.lang.String name)
|
void |
setServeDynamicSystemServlets(boolean b)
Deprecated. Use org.openqa.jetty.jetty.servlet.Invoker |
void |
setSessionInactiveInterval(int seconds)
Set the session timeout interval in seconds. |
void |
setSessionManager(SessionManager sm)
|
void |
setUsingCookies(boolean uc)
|
Methods inherited from class org.openqa.jetty.util.Container |
---|
addComponent, addEventListener, getComponents, isStarted, isStarting, isStopping, removeComponent, removeEventListener, start, stop |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.openqa.jetty.util.LifeCycle |
---|
isStarted, start, stop |
Field Detail |
---|
public static final java.lang.String __DEFAULT_SERVLET
public static final java.lang.String __J_S_CONTEXT_TEMPDIR
public static final java.lang.String __J_S_ERROR_EXCEPTION
public static final java.lang.String __J_S_ERROR_EXCEPTION_TYPE
public static final java.lang.String __J_S_ERROR_MESSAGE
public static final java.lang.String __J_S_ERROR_REQUEST_URI
public static final java.lang.String __J_S_ERROR_SERVLET_NAME
public static final java.lang.String __J_S_ERROR_STATUS_CODE
protected PathMap _servletMap
protected java.util.Map _nameMap
protected java.util.Map _attributes
protected java.lang.String _formLoginPage
protected java.lang.String _formErrorPage
protected SessionManager _sessionManager
protected transient org.openqa.jetty.jetty.servlet.ServletHandler.Context _context
protected transient java.lang.ClassLoader _loader
protected transient org.apache.commons.logging.Log _contextLog
protected transient HttpContext _httpContext
Constructor Detail |
---|
public ServletHandler()
Method Detail |
---|
public void setName(java.lang.String name)
public java.lang.String getName()
HttpHandler
getName
in interface HttpHandler
public HttpContext getHttpContext()
getHttpContext
in interface HttpHandler
public void initialize(HttpContext context)
initialize
in interface HttpHandler
public void formAuthInit(java.lang.String formLoginPage, java.lang.String formErrorPage)
public void setSessionManager(SessionManager sm)
public SessionManager getSessionManager()
public javax.servlet.ServletContext getServletContext()
public PathMap getServletMap()
public boolean isUsingCookies()
public void setDynamicServletPathSpec(java.lang.String dynamicServletPathSpec)
public void setDynamicInitParams(java.util.Map initParams)
public void setServeDynamicSystemServlets(boolean b)
public java.lang.ClassLoader getClassLoader()
public void setUsingCookies(boolean uc)
uc
- If true, cookies are used for sessionspublic ServletHolder newServletHolder(java.lang.String name, java.lang.String servletClass, java.lang.String forcedPath)
public ServletHolder newServletHolder(java.lang.String name, java.lang.String servletClass)
public ServletHolder getServletHolder(java.lang.String name)
public ServletHolder mapPathToServlet(java.lang.String pathSpec, java.lang.String servletName)
pathSpec
- The pathspec to mapservletName
- The name of the servlet, which must have already been added.
public ServletHolder addServlet(java.lang.String name, java.lang.String pathSpec, java.lang.String servletClass, java.lang.String forcedPath)
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.
public ServletHolder addServlet(java.lang.String name, java.lang.String pathSpec, java.lang.String servletClass)
name
- The servlet name.pathSpec
- A path specification to map this servlet to.servletClass
- The class name of the servlet.
public ServletHolder addServlet(java.lang.String pathSpec, java.lang.String servletClass)
pathSpec
- The pathmappingservletClass
- The class of the servlet
public void addServletHolder(ServletHolder holder)
holder
- the ServletHolder to register.public boolean isAutoInitializeServlets()
public void setAutoInitializeServlets(boolean b)
protected void doStart() throws java.lang.Exception
Container
doStart
in class Container
java.lang.Exception
public ServletHolder[] getServlets()
public void initializeServlets() throws java.lang.Exception
java.lang.Exception
protected void doStop() throws java.lang.Exception
Container
doStop
in class Container
java.lang.Exception
public javax.servlet.http.HttpSession getHttpSession(java.lang.String id)
public javax.servlet.http.HttpSession newHttpSession(javax.servlet.http.HttpServletRequest request)
public void setSessionInactiveInterval(int seconds)
seconds
- the length of the session timeout interval in seconds.public void handle(java.lang.String pathInContext, java.lang.String pathParams, HttpRequest httpRequest, HttpResponse httpResponse) throws java.io.IOException
handle
in interface HttpHandler
pathInContext
- pathParams
- httpRequest
- httpResponse
-
java.io.IOException
protected void dispatch(java.lang.String pathInContext, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, ServletHolder servletHolder, int type) throws javax.servlet.ServletException, javax.servlet.UnavailableException, java.io.IOException
pathInContext
- The path used to select the servlet holder.request
- response
- servletHolder
- type
- the type of dispatch as defined in the Dispatcher class.
javax.servlet.ServletException
javax.servlet.UnavailableException
java.io.IOException
public java.util.Map.Entry getHolderEntry(java.lang.String pathInContext)
pathInContext
- Path within context.
public java.util.Set getResourcePaths(java.lang.String uriInContext)
public java.net.URL getResource(java.lang.String uriInContext) throws java.net.MalformedURLException
uriInContext
-
java.net.MalformedURLException
public java.io.InputStream getResourceAsStream(java.lang.String uriInContext)
public java.lang.String getRealPath(java.lang.String path)
public javax.servlet.RequestDispatcher getRequestDispatcher(java.lang.String uriInContext)
public javax.servlet.RequestDispatcher getNamedDispatcher(java.lang.String name)
name
- The name of the servlet. If null or empty string, the
containers default servlet is returned.
protected void notFound(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.io.IOException
java.io.IOException
protected void handleTrace(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.io.IOException
java.io.IOException
protected void handleOptions(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.io.IOException
java.io.IOException
public java.lang.String getErrorPage(int status, ServletHttpRequest request)
protected java.lang.Object getContextAttribute(java.lang.String name)
name
- attribute name.
protected java.util.Enumeration getContextAttributeNames()
protected void setContextAttribute(java.lang.String name, java.lang.Object value)
protected void removeContextAttribute(java.lang.String name)
public void handleTrace(HttpRequest request, HttpResponse response) throws java.io.IOException
java.io.IOException
public void destroy()
Container
destroy
in class Container
protected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |