|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjavax.servlet.ServletRequestWrapper
public class ServletRequestWrapper
Provides a convenient implementation of the ServletRequest interface that can be subclassed by developers wishing to adapt the request to a Servlet. This class implements the Wrapper or Decorator pattern. Methods default to calling through to the wrapped request object.
ServletRequest| Constructor Summary | |
|---|---|
ServletRequestWrapper(ServletRequest request)
Creates a ServletRequest adaptor wrapping the given request object. |
|
| Method Summary | |
|---|---|
void |
complete()
Complete a suspended request. |
java.lang.Object |
getAttribute(java.lang.String name)
The default behavior of this method is to call getAttribute(String name) on the wrapped request object. |
java.util.Enumeration |
getAttributeNames()
The default behavior of this method is to return getAttributeNames() on the wrapped request object. |
java.lang.String |
getCharacterEncoding()
The default behavior of this method is to return getCharacterEncoding() on the wrapped request object. |
int |
getContentLength()
The default behavior of this method is to return getContentLength() on the wrapped request object. |
java.lang.String |
getContentType()
The default behavior of this method is to return getContentType() on the wrapped request object. |
ServletInputStream |
getInputStream()
The default behavior of this method is to return getInputStream() on the wrapped request object. |
java.lang.String |
getLocalAddr()
The default behavior of this method is to return getLocalAddr() on the wrapped request object. |
java.util.Locale |
getLocale()
The default behavior of this method is to return getLocale() on the wrapped request object. |
java.util.Enumeration |
getLocales()
The default behavior of this method is to return getLocales() on the wrapped request object. |
java.lang.String |
getLocalName()
The default behavior of this method is to return getLocalName() on the wrapped request object. |
int |
getLocalPort()
The default behavior of this method is to return getLocalPort() on the wrapped request object. |
java.lang.String |
getParameter(java.lang.String name)
The default behavior of this method is to return getParameter(String name) on the wrapped request object. |
java.util.Map |
getParameterMap()
The default behavior of this method is to return getParameterMap() on the wrapped request object. |
java.util.Enumeration |
getParameterNames()
The default behavior of this method is to return getParameterNames() on the wrapped request object. |
java.lang.String[] |
getParameterValues(java.lang.String name)
The default behavior of this method is to return getParameterValues(String name) on the wrapped request object. |
java.lang.String |
getProtocol()
The default behavior of this method is to return getProtocol() on the wrapped request object. |
java.io.BufferedReader |
getReader()
The default behavior of this method is to return getReader() on the wrapped request object. |
java.lang.String |
getRealPath(java.lang.String path)
The default behavior of this method is to return getRealPath(String path) on the wrapped request object. |
java.lang.String |
getRemoteAddr()
The default behavior of this method is to return getRemoteAddr() on the wrapped request object. |
java.lang.String |
getRemoteHost()
The default behavior of this method is to return getRemoteHost() on the wrapped request object. |
int |
getRemotePort()
The default behavior of this method is to return getRemotePort() on the wrapped request object. |
ServletRequest |
getRequest()
Return the wrapped request object. |
RequestDispatcher |
getRequestDispatcher(java.lang.String path)
The default behavior of this method is to return getRequestDispatcher(String path) on the wrapped request object. |
java.lang.String |
getScheme()
The default behavior of this method is to return getScheme() on the wrapped request object. |
java.lang.String |
getServerName()
The default behavior of this method is to return getServerName() on the wrapped request object. |
int |
getServerPort()
The default behavior of this method is to return getServerPort() on the wrapped request object. |
ServletContext |
getServletContext()
Gets the servlet context to which this servlet request was last dispatched. |
ServletResponse |
getServletResponse()
Gets the servlet response with which this servlet request has been associated. |
boolean |
isInitial()
|
boolean |
isResumed()
|
boolean |
isSecure()
The default behavior of this method is to return isSecure() on the wrapped request object. |
boolean |
isSuspended()
|
boolean |
isTimeout()
|
void |
removeAttribute(java.lang.String name)
The default behavior of this method is to call removeAttribute(String name) on the wrapped request object. |
void |
resume()
Resume a suspended request. |
void |
setAttribute(java.lang.String name,
java.lang.Object o)
The default behavior of this method is to return setAttribute(String name, Object o) on the wrapped request object. |
void |
setCharacterEncoding(java.lang.String enc)
The default behavior of this method is to set the character encoding on the wrapped request object. |
void |
setRequest(ServletRequest request)
Sets the request object being wrapped. |
void |
suspend()
Suspend the processing of the request and associated ServletResponse. |
void |
suspend(long timeoutMs)
Suspend the processing of the request and associated ServletResponse. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ServletRequestWrapper(ServletRequest request)
java.lang.IllegalArgumentException - if the request is null| Method Detail |
|---|
public ServletRequest getRequest()
public void setRequest(ServletRequest request)
java.lang.IllegalArgumentException - if the request is null.public java.lang.Object getAttribute(java.lang.String name)
getAttribute in interface ServletRequestname - a String specifying the name of
the attribute
Object containing the value
of the attribute, or null if
the attribute does not existpublic java.util.Enumeration getAttributeNames()
getAttributeNames in interface ServletRequestEnumeration of strings
containing the names
of the request's attributespublic java.lang.String getCharacterEncoding()
getCharacterEncoding in interface ServletRequestString containing the name of
the character encoding, or null
if the request does not specify a character encoding
public void setCharacterEncoding(java.lang.String enc)
throws java.io.UnsupportedEncodingException
setCharacterEncoding in interface ServletRequestenc - a String containing the name of
the character encoding.
java.io.UnsupportedEncodingException - if this is not a valid encodingpublic int getContentLength()
getContentLength in interface ServletRequestpublic java.lang.String getContentType()
getContentType in interface ServletRequestString containing the name
of the MIME type of
the request, or null if the type is not known
public ServletInputStream getInputStream()
throws java.io.IOException
getInputStream in interface ServletRequestServletInputStream object containing
the body of the request
java.io.IOException - if an input or output exception occurredpublic java.lang.String getParameter(java.lang.String name)
getParameter in interface ServletRequestname - a String specifying the
name of the parameter
String representing the
single value of the parameterServletRequest.getParameterValues(java.lang.String)public java.util.Map getParameterMap()
getParameterMap in interface ServletRequestpublic java.util.Enumeration getParameterNames()
getParameterNames in interface ServletRequestEnumeration of String
objects, each String containing
the name of a request parameter; or an
empty Enumeration if the
request has no parameterspublic java.lang.String[] getParameterValues(java.lang.String name)
getParameterValues in interface ServletRequestname - a String containing the name of
the parameter whose value is requested
String objects
containing the parameter's valuesServletRequest.getParameter(java.lang.String)public java.lang.String getProtocol()
getProtocol in interface ServletRequestString containing the protocol
name and version numberpublic java.lang.String getScheme()
getScheme in interface ServletRequestString containing the name
of the scheme used to make this requestpublic java.lang.String getServerName()
getServerName in interface ServletRequestString containing the name
of the serverpublic int getServerPort()
getServerPort in interface ServletRequest
public java.io.BufferedReader getReader()
throws java.io.IOException
getReader in interface ServletRequestBufferedReader
containing the body of the request
java.io.IOException - if an input or output exception occurredServletRequest.getInputStream()public java.lang.String getRemoteAddr()
getRemoteAddr in interface ServletRequestString containing the
IP address of the client that sent the requestpublic java.lang.String getRemoteHost()
getRemoteHost in interface ServletRequestString containing the fully
qualified name of the client
public void setAttribute(java.lang.String name,
java.lang.Object o)
setAttribute in interface ServletRequestname - a String specifying
the name of the attributeo - the Object to be storedpublic void removeAttribute(java.lang.String name)
removeAttribute in interface ServletRequestname - a String specifying
the name of the attribute to removepublic java.util.Locale getLocale()
getLocale in interface ServletRequestLocale for the clientpublic java.util.Enumeration getLocales()
getLocales in interface ServletRequestEnumeration of preferred
Locale objects for the clientpublic boolean isSecure()
isSecure in interface ServletRequestpublic RequestDispatcher getRequestDispatcher(java.lang.String path)
getRequestDispatcher in interface ServletRequestpath - a String specifying the pathname
to the resource. If it is relative, it must be
relative against the current servlet.
RequestDispatcher object
that acts as a wrapper for the resource
at the specified path, or null
if the servlet container cannot return a
RequestDispatcherRequestDispatcher,
ServletContext.getRequestDispatcher(java.lang.String)public java.lang.String getRealPath(java.lang.String path)
getRealPath in interface ServletRequestpublic int getRemotePort()
getRemotePort in interface ServletRequestpublic java.lang.String getLocalName()
getLocalName in interface ServletRequestString containing the host
name of the IP on which the request was received.public java.lang.String getLocalAddr()
getLocalAddr in interface ServletRequestString containing the
IP address on which the request was received.public int getLocalPort()
getLocalPort in interface ServletRequest
public void complete()
throws java.io.IOException
ServletRequestThis method can be called by any thread that has been passed a reference to a suspended request. When a request is completed, the associated response object commited and flushed. The request is not redispatched.
If complete is called before a suspended request is returned to the container
(ie the thread that called ServletRequest.suspend(long) is still within the filter
chain and/or servlet service method), then the complete does not take effect until
the call to the filter chain and/or servlet returns to the container. In this
case both ServletRequest.isSuspended() and ServletRequest.isResumed() return true.
Once complete has been called and any thread calling the filter chain and/or servlet chain has returned to the container, the request lifecycle is complete. The container is able to recycle request objects, so it is not valid hold a request reference after the end of the life cycle or to call any request methods.
complete in interface ServletRequestjava.io.IOExceptionServletRequest.complete()public boolean isInitial()
isInitial in interface ServletRequestServletRequest.isInitial()public boolean isResumed()
isResumed in interface ServletRequestServletRequest.isResumed()public boolean isSuspended()
isSuspended in interface ServletRequestServletRequest.isSuspended()public boolean isTimeout()
isTimeout in interface ServletRequestServletRequest.isTimeout()public void resume()
ServletRequestThis method can be called by any thread that has been passed a reference to a suspended request. When called the request is redispatched to the normal filter chain and servlet processing.
If resume is called before a suspended request is returned to the container
(ie the thread that called ServletRequest.suspend(long) is still within the filter
chain and/or servlet service method), then the resume does not take effect until
the call to the filter chain and/or servlet returns to the container. In this
case both ServletRequest.isSuspended() and ServletRequest.isResumed() return true.
Multiple calls to resume are ignored
resume in interface ServletRequestServletRequest.resume()public void suspend()
ServletRequestServletResponse.
Acts as a call to ServletRequest.suspend(long) but with a container supplied
timeout. The timeout the container will use may be obtained or set as a Long
context attribute with the name "javax.servlet.suspendTimeoutMs"
suspend in interface ServletRequestServletRequest.suspend()public void suspend(long timeoutMs)
ServletRequestServletResponse.
After this method has been called, the lifecycle of the request
will be extended beyond the return to the container from the
Servlet.service(ServletRequest, ServletResponse) method and
Filter.doFilter(ServletRequest, ServletResponse, FilterChain) calls. If a
request is suspended, then the container will not commit the associated response
when the call to the filter chain and/or servlet service method returns to the
container. Any exceptions thrown to the container by a filter chain and/or
servlet for a suspended requests are silently ignored.
When the thread calling the filter chain and/or servlet has returned to the container with a suspended request, the thread is freed for other tasks and the request is held pending either:
ServletRequest.resume().ServletRequest.complete().After any of the events listed above, the suspended request will be redispatched via the filter and servlet processing.
If a request is already suspended, any subsequent calls to suspend will set the timeout to the minimum of the previous timeout and the newly passed timeout
Suspend may only be called by a thread that is within the service calling
stack of Filter.doFilter(ServletRequest, ServletResponse, FilterChain)
and/or Servlet.service(ServletRequest, ServletResponse). A request that has
been dispatched for error handling may not be suspended.
suspend in interface ServletRequesttimeoutMs - ServletRequest.suspend(long)public ServletContext getServletContext()
ServletRequest
getServletContext in interface ServletRequestServletRequest.getServletContext()public ServletResponse getServletResponse()
ServletRequest
getServletResponse in interface ServletRequestServletRequest.getServletResponse()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||