org.apache.struts.upload

Class MultipartRequestWrapper

public class MultipartRequestWrapper extends Object implements HttpServletRequest

This class functions as a wrapper around HttpServletRequest to provide working getParameter methods for multipart requests. Once Struts requires Servlet 2.3, this class will definately be changed to extend javax.servlet.http.HttpServletRequestWrapper instead of implementing HttpServletRequest. Servlet 2.3 methods are implemented to return null or do nothing if called on. Use getRequest to retrieve the underlying HttpServletRequest object and call on the 2.3 method there, the empty methods are here only so that this will compile with the Servlet 2.3 jar. This class exists temporarily in the process() method of ActionServlet, just before the ActionForward is processed and just after the Action is performed, the request is set back to the original HttpServletRequest object.
Field Summary
static Loglog
Logging instance
protected Mapparameters
The parameters for this multipart request
protected HttpServletRequestrequest
The underlying HttpServletRequest
Constructor Summary
MultipartRequestWrapper(HttpServletRequest request)
Method Summary
ObjectgetAttribute(String name)
EnumerationgetAttributeNames()
StringgetAuthType()
StringgetCharacterEncoding()
intgetContentLength()
StringgetContentType()
StringgetContextPath()
Cookie[]getCookies()
longgetDateHeader(String name)
StringgetHeader(String name)
EnumerationgetHeaderNames()
EnumerationgetHeaders(String name)
ServletInputStreamgetInputStream()
intgetIntHeader(String name)
StringgetLocalAddr()
Use Reflection to invoke Servlet 2.4 getLocalAddr method on the wrapped Request.
LocalegetLocale()
EnumerationgetLocales()
StringgetLocalName()
Use Reflection to invoke Servlet 2.4 getLocalName method on the wrapped Request.
intgetLocalPort()
Use Reflection to invoke Servlet 2.4 getLocalPort method on the wrapped Request.
StringgetMethod()
StringgetParameter(String name)
Attempts to get a parameter for this request.
MapgetParameterMap()
Implements the Servlet 2.3 getParameterMap method.
EnumerationgetParameterNames()
Returns the names of the parameters for this request.
String[]getParameterValues(String name)
StringgetPathInfo()
StringgetPathTranslated()
StringgetProtocol()
StringgetQueryString()
BufferedReadergetReader()
StringgetRealPath(String path)
StringgetRemoteAddr()
StringgetRemoteHost()
intgetRemotePort()
Use Reflection to invoke Servlet 2.4 getRemotePort method on the wrapped Request.
StringgetRemoteUser()
HttpServletRequestgetRequest()
Returns the underlying HttpServletRequest for this wrapper
RequestDispatchergetRequestDispatcher(String path)
StringgetRequestedSessionId()
StringgetRequestURI()
StringBuffergetRequestURL()
Use Reflection to invoke Servlet 2.3 getRequestURL method on the wrapped Request.
StringgetScheme()
StringgetServerName()
intgetServerPort()
StringgetServletPath()
HttpSessiongetSession(boolean create)
HttpSessiongetSession()
PrincipalgetUserPrincipal()
ObjectinvokeRequestMethod(String name, Object[] args)
Convenience method which uses reflection to invoke a method on the Request.
booleanisRequestedSessionIdFromCookie()
Use Reflection to invoke Servlet 2.3 isRequestedSessionIdFromCookie method on the wrapped Request.
booleanisRequestedSessionIdFromUrl()
booleanisRequestedSessionIdFromURL()
booleanisRequestedSessionIdValid()
booleanisSecure()
booleanisUserInRole(String user)
voidremoveAttribute(String name)
voidsetAttribute(String name, Object o)
voidsetCharacterEncoding(String encoding)
Use Reflection to invoke Servlet 2.3 setCharacterEncoding method on the wrapped Request.
voidsetParameter(String name, String value)
Sets a parameter for this request.

Field Detail

log

private static final Log log
Logging instance

parameters

protected Map parameters
The parameters for this multipart request

request

protected HttpServletRequest request
The underlying HttpServletRequest

Constructor Detail

MultipartRequestWrapper

public MultipartRequestWrapper(HttpServletRequest request)

Method Detail

getAttribute

public Object getAttribute(String name)

getAttributeNames

public Enumeration getAttributeNames()

getAuthType

public String getAuthType()

getCharacterEncoding

public String getCharacterEncoding()

getContentLength

public int getContentLength()

getContentType

public String getContentType()

getContextPath

public String getContextPath()

getCookies

public Cookie[] getCookies()

getDateHeader

public long getDateHeader(String name)

getHeader

public String getHeader(String name)

getHeaderNames

public Enumeration getHeaderNames()

getHeaders

public Enumeration getHeaders(String name)

getInputStream

public ServletInputStream getInputStream()

getIntHeader

public int getIntHeader(String name)

getLocalAddr

public String getLocalAddr()
Use Reflection to invoke Servlet 2.4 getLocalAddr method on the wrapped Request.

getLocale

public Locale getLocale()

getLocales

public Enumeration getLocales()

getLocalName

public String getLocalName()
Use Reflection to invoke Servlet 2.4 getLocalName method on the wrapped Request.

getLocalPort

public int getLocalPort()
Use Reflection to invoke Servlet 2.4 getLocalPort method on the wrapped Request.

getMethod

public String getMethod()

getParameter

public String getParameter(String name)
Attempts to get a parameter for this request. It first looks in the underlying HttpServletRequest object for the parameter, and if that doesn't exist it looks for the parameters retrieved from the multipart request

getParameterMap

public Map getParameterMap()
Implements the Servlet 2.3 getParameterMap method.

getParameterNames

public Enumeration getParameterNames()
Returns the names of the parameters for this request. The enumeration consists of the normal request parameter names plus the parameters read from the multipart request

getParameterValues

public String[] getParameterValues(String name)

getPathInfo

public String getPathInfo()

getPathTranslated

public String getPathTranslated()

getProtocol

public String getProtocol()

getQueryString

public String getQueryString()

getReader

public BufferedReader getReader()

getRealPath

public String getRealPath(String path)

getRemoteAddr

public String getRemoteAddr()

getRemoteHost

public String getRemoteHost()

getRemotePort

public int getRemotePort()
Use Reflection to invoke Servlet 2.4 getRemotePort method on the wrapped Request.

getRemoteUser

public String getRemoteUser()

getRequest

public HttpServletRequest getRequest()
Returns the underlying HttpServletRequest for this wrapper

getRequestDispatcher

public RequestDispatcher getRequestDispatcher(String path)

getRequestedSessionId

public String getRequestedSessionId()

getRequestURI

public String getRequestURI()

getRequestURL

public StringBuffer getRequestURL()
Use Reflection to invoke Servlet 2.3 getRequestURL method on the wrapped Request.

getScheme

public String getScheme()

getServerName

public String getServerName()

getServerPort

public int getServerPort()

getServletPath

public String getServletPath()

getSession

public HttpSession getSession(boolean create)

getSession

public HttpSession getSession()

getUserPrincipal

public Principal getUserPrincipal()

invokeRequestMethod

private Object invokeRequestMethod(String name, Object[] args)
Convenience method which uses reflection to invoke a method on the Request.

isRequestedSessionIdFromCookie

public boolean isRequestedSessionIdFromCookie()
Use Reflection to invoke Servlet 2.3 isRequestedSessionIdFromCookie method on the wrapped Request.

isRequestedSessionIdFromUrl

public boolean isRequestedSessionIdFromUrl()

isRequestedSessionIdFromURL

public boolean isRequestedSessionIdFromURL()

isRequestedSessionIdValid

public boolean isRequestedSessionIdValid()

isSecure

public boolean isSecure()

isUserInRole

public boolean isUserInRole(String user)

removeAttribute

public void removeAttribute(String name)

setAttribute

public void setAttribute(String name, Object o)

setCharacterEncoding

public void setCharacterEncoding(String encoding)
Use Reflection to invoke Servlet 2.3 setCharacterEncoding method on the wrapped Request.

setParameter

public void setParameter(String name, String value)
Sets a parameter for this request. The parameter is actually separate from the request parameters, but calling on the getParameter() methods of this class will work as if they weren't.
Copyright B) 2000-2009 - The Apache Software Foundation