|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjavax.servlet.ServletRequestWrapper
public class ServletRequestWrapper
Wraps a servlet request in another request. Filters may use ServletRequestWrapper to modify the headers passed to the servlet.
The default methods just call the wrapped request methods.
| Constructor Summary | |
|---|---|
ServletRequestWrapper(ServletRequest request)
Create a new ServletRequestWrapper wrapping the enclosed request. |
|
| Method Summary | |
|---|---|
java.lang.Object |
getAttribute(java.lang.String name)
Returns an attribute value. |
java.util.Enumeration |
getAttributeNames()
Enumerates all attribute names in the request. |
java.lang.String |
getCharacterEncoding()
Returns the character encoding of the POSTed data. |
int |
getContentLength()
Returns the content length of the data. |
java.lang.String |
getContentType()
Returns the request's mime-type. |
ServletInputStream |
getInputStream()
Returns an InputStream to retrieve POST data from the request. |
java.lang.String |
getLocalAddr()
Returns the IP address of the local host, i.e. |
java.util.Locale |
getLocale()
Returns the request's preferred locale. |
java.util.Enumeration |
getLocales()
Returns an enumeration of all locales acceptable by the client. |
java.lang.String |
getLocalName()
Returns the local host name. |
int |
getLocalPort()
Returns the local port |
java.lang.String |
getParameter(java.lang.String name)
Returns a form parameter. |
java.util.Map |
getParameterMap()
Returns the parameter map request parameters. |
java.util.Enumeration |
getParameterNames()
Returns an enumeration of all form parameter names. |
java.lang.String[] |
getParameterValues(java.lang.String name)
Returns all values of a form parameter. |
java.lang.String |
getProtocol()
Returns the prococol, e.g. |
java.io.BufferedReader |
getReader()
Returns a reader to read POSTed data. |
java.lang.String |
getRealPath(java.lang.String uri)
Returns the real path. |
java.lang.String |
getRemoteAddr()
Returns the IP address of the remote host, i.e. |
java.lang.String |
getRemoteHost()
Returns the DNS hostname of the remote host, i.e. |
int |
getRemotePort()
Returns the remote port |
ServletRequest |
getRequest()
Gets the request object being wrapped. |
RequestDispatcher |
getRequestDispatcher(java.lang.String uri)
Returns a request dispatcher for later inclusion or forwarding. |
java.lang.String |
getScheme()
Returns the request scheme, e.g. |
java.lang.String |
getServerName()
Returns the server name handling the request. |
int |
getServerPort()
Returns the server port handling the request, e.g. |
boolean |
isSecure()
Returns true if the connection is secure, e.g. |
void |
removeAttribute(java.lang.String name)
Removes the given attribute. |
void |
setAttribute(java.lang.String name,
java.lang.Object o)
Sets an attribute value. |
void |
setCharacterEncoding(java.lang.String encoding)
Sets the character encoding to be used for forms and getReader. |
void |
setRequest(ServletRequest request)
Sets the request object being wrapped. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ServletRequestWrapper(ServletRequest request)
| Method Detail |
|---|
public void setRequest(ServletRequest request)
java.lang.IllegalArgumentException - if the request is nullpublic ServletRequest getRequest()
public java.lang.String getProtocol()
getProtocol in interface ServletRequestpublic java.lang.String getScheme()
getScheme in interface ServletRequestpublic java.lang.String getServerName()
getServerName in interface ServletRequestpublic int getServerPort()
getServerPort in interface ServletRequestpublic java.lang.String getRemoteAddr()
getRemoteAddr in interface ServletRequestpublic java.lang.String getRemoteHost()
getRemoteHost in interface ServletRequestpublic int getRemotePort()
getRemotePort in interface ServletRequestpublic java.lang.String getLocalAddr()
getLocalAddr in interface ServletRequestpublic java.lang.String getLocalName()
getLocalName in interface ServletRequestpublic int getLocalPort()
getLocalPort in interface ServletRequestpublic java.lang.String getParameter(java.lang.String name)
getParameter returns the first.
For example, calling getParameter("a") with the
the query string a=1&a=2 will return "1".
getParameter in interface ServletRequestname - the form parameter to return
public java.util.Map getParameterMap()
getParameterMap in interface ServletRequestpublic java.lang.String[] getParameterValues(java.lang.String name)
For example, calling getParameterValues("a")
with the the query string a=1&a=2 will
return ["1", "2"].
getParameterValues in interface ServletRequestname - the form parameter to return
public java.util.Enumeration getParameterNames()
Enumeration e = _request.getParameterNames();
while (e.hasMoreElements()) {
String name = (String) e.nextElement();
out.println(name + ": " + request.getParameter(name));
}
getParameterNames in interface ServletRequest
public ServletInputStream getInputStream()
throws java.io.IOException
getInputStream in interface ServletRequestjava.io.IOException
public java.io.BufferedReader getReader()
throws java.io.IOException,
java.lang.IllegalStateException
getCharacterEncoding()
getReader in interface ServletRequestjava.io.IOException
java.lang.IllegalStateExceptionpublic java.lang.String getCharacterEncoding()
getCharacterEncoding in interface ServletRequest
public void setCharacterEncoding(java.lang.String encoding)
throws java.io.UnsupportedEncodingException
setCharacterEncoding in interface ServletRequestjava.io.UnsupportedEncodingExceptionpublic int getContentLength()
The upshot is, rely on the input stream to end when the data completes.
getContentLength in interface ServletRequestpublic java.lang.String getContentType()
getContentType in interface ServletRequestpublic java.util.Locale getLocale()
getLocale in interface ServletRequestpublic java.util.Enumeration getLocales()
getLocales in interface ServletRequestpublic boolean isSecure()
isSecure in interface ServletRequestpublic java.lang.Object getAttribute(java.lang.String name)
getAttribute in interface ServletRequestname - the attribute name
public void setAttribute(java.lang.String name,
java.lang.Object o)
setAttribute in interface ServletRequestname - the attribute nameo - the attribute valuepublic java.util.Enumeration getAttributeNames()
getAttributeNames in interface ServletRequestpublic void removeAttribute(java.lang.String name)
removeAttribute in interface ServletRequestname - the attribute namepublic RequestDispatcher getRequestDispatcher(java.lang.String uri)
uri
is relative to the request URI. Absolute URIs are relative to
the application prefix (getContextPath()).
If getRequestURI() is /myapp/dir/test.jsp and the
uri is "inc.jsp", the resulting page is
/myapp/dir/inc.jsp.
RequestDispatcher disp;
disp = getRequestDispatcher("inc.jsp?a=b");
disp.include(request, response);
getRequestDispatcher in interface ServletRequesturi - path relative to getRequestURI()
(including query string) for the included file.
public java.lang.String getRealPath(java.lang.String uri)
getRealPath in interface ServletRequest
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||