public class ServletRequestWrapper extends java.lang.Object implements ServletRequest
ServletRequest| Constructor and Description |
|---|
ServletRequestWrapper(ServletRequest request)
Creates a ServletRequest adaptor wrapping the given request object.
|
| Modifier and Type | Method and Description |
|---|---|
AsyncContext |
getAsyncContext()
Gets the AsyncContext that was created or reinitialized by the most recent invocation of
startAsync() or
startAsync(ServletRequest,ServletResponse) on the wrapped 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<java.lang.String> |
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.
|
long |
getContentLengthLong()
The default behavior of this method is to return getContentLengthLong() on the wrapped request object.
|
java.lang.String |
getContentType()
The default behavior of this method is to return getContentType() on the wrapped request object.
|
DispatcherType |
getDispatcherType()
Gets the dispatcher type of the wrapped request.
|
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<java.util.Locale> |
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<java.lang.String,java.lang.String[]> |
getParameterMap()
The default behavior of this method is to return getParameterMap() on the wrapped request object.
|
java.util.Enumeration<java.lang.String> |
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)
Deprecated.
As of Version 2.1 of the Java Servlet API, use
ServletContext.getRealPath(java.lang.String) instead |
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 the wrapped servlet request was last dispatched.
|
boolean |
isAsyncStarted()
Checks if the wrapped request has been put into asynchronous mode.
|
boolean |
isAsyncSupported()
Checks if the wrapped request supports asynchronous operation.
|
boolean |
isSecure()
The default behavior of this method is to return isSecure() on the wrapped request object.
|
boolean |
isWrapperFor(java.lang.Class<?> wrappedType)
Checks (recursively) if this ServletRequestWrapper wraps a
ServletRequest of the given class type. |
boolean |
isWrapperFor(ServletRequest wrapped)
Checks (recursively) if this ServletRequestWrapper wraps the given
ServletRequest instance. |
void |
removeAttribute(java.lang.String name)
The default behavior of this method is to call removeAttribute(String name) on the wrapped request object.
|
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.
|
AsyncContext |
startAsync()
The default behavior of this method is to invoke
ServletRequest.startAsync() on the wrapped request object. |
AsyncContext |
startAsync(ServletRequest servletRequest,
ServletResponse servletResponse)
The default behavior of this method is to invoke
ServletRequest.startAsync(ServletRequest, ServletResponse)
on the wrapped request object. |
public ServletRequestWrapper(ServletRequest request)
request - the ServletRequest to be wrappedjava.lang.IllegalArgumentException - if the request is nullpublic ServletRequest getRequest()
ServletRequestpublic void setRequest(ServletRequest request)
request - the ServletRequest to be installedjava.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 attributeObject containing the value of the attribute, or null if the attribute does not
existpublic java.util.Enumeration<java.lang.String> 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 encodingpublic void setCharacterEncoding(java.lang.String enc)
throws java.io.UnsupportedEncodingException
setCharacterEncoding in interface ServletRequestenc - String containing the name of the character encoding.java.io.UnsupportedEncodingException - if this ServletRequest is still in a state where a character encoding may be
set, but the specified encoding is invalidpublic int getContentLength()
getContentLength in interface ServletRequestpublic long getContentLengthLong()
getContentLengthLong 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 knownpublic ServletInputStream getInputStream() throws java.io.IOException
getInputStream in interface ServletRequestServletInputStream object containing the body of the requestjava.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 parameterString representing the single value of the parameterServletRequest.getParameterValues(java.lang.String)public java.util.Map<java.lang.String,java.lang.String[]> getParameterMap()
getParameterMap in interface ServletRequestpublic java.util.Enumeration<java.lang.String> 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 requestedString 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 ServletRequestpublic java.io.BufferedReader getReader()
throws java.io.IOException
getReader in interface ServletRequestBufferedReader containing the body of the requestjava.io.UnsupportedEncodingException - if the character set encoding used is not supported and the text cannot be
decodedjava.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 clientpublic 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<java.util.Locale> 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)@Deprecated public java.lang.String getRealPath(java.lang.String path)
ServletContext.getRealPath(java.lang.String) insteadgetRealPath in interface ServletRequestpath - the path for which the real path is to be returned.public 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 ServletRequestpublic ServletContext getServletContext()
getServletContext in interface ServletRequestpublic AsyncContext startAsync() throws java.lang.IllegalStateException
ServletRequest.startAsync() on the wrapped request object.startAsync in interface ServletRequestjava.lang.IllegalStateException - if the request is within the scope of a filter or servlet that does not support
asynchronous operations (that is, isAsyncSupported() returns false), or if this method is called again without
any asynchronous dispatch (resulting from one of the AsyncContext.dispatch() methods), is called outside the
scope of any such dispatch, or is called again within the scope of the same dispatch, or if the response has already
been closedServletRequest.startAsync()public AsyncContext startAsync(ServletRequest servletRequest, ServletResponse servletResponse) throws java.lang.IllegalStateException
ServletRequest.startAsync(ServletRequest, ServletResponse)
on the wrapped request object.startAsync in interface ServletRequestservletRequest - the ServletRequest used to initialize the AsyncContextservletResponse - the ServletResponse used to initialize the AsyncContextjava.lang.IllegalStateException - if the request is within the scope of a filter or servlet that does not support
asynchronous operations (that is, isAsyncSupported() returns false), or if this method is called again without
any asynchronous dispatch (resulting from one of the AsyncContext.dispatch() methods), is called outside the
scope of any such dispatch, or is called again within the scope of the same dispatch, or if the response has already
been closedServletRequest.startAsync(ServletRequest, ServletResponse)public boolean isAsyncStarted()
isAsyncStarted in interface ServletRequestServletRequest.isAsyncStarted()public boolean isAsyncSupported()
isAsyncSupported in interface ServletRequestServletRequest.isAsyncSupported()public AsyncContext getAsyncContext()
startAsync() or
startAsync(ServletRequest,ServletResponse) on the wrapped request.getAsyncContext in interface ServletRequeststartAsync() or
startAsync(ServletRequest,ServletResponse) on the wrapped requestjava.lang.IllegalStateException - if this request has not been put into asynchronous mode, i.e., if neither
startAsync() nor startAsync(ServletRequest,ServletResponse) has been calledServletRequest.getAsyncContext()public boolean isWrapperFor(ServletRequest wrapped)
ServletRequest instance.wrapped - the ServletRequest instance to search forpublic boolean isWrapperFor(java.lang.Class<?> wrappedType)
ServletRequest of the given class type.wrappedType - the ServletRequest class type to search forjava.lang.IllegalArgumentException - if the given class does not implement ServletRequestpublic DispatcherType getDispatcherType()
getDispatcherType in interface ServletRequestServletRequest.getDispatcherType()