org.apache.struts.upload

Class MultipartRequestWrapper

Implemented Interfaces:
HttpServletRequest

public class MultipartRequestWrapper
extends java.lang.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

private static Log
log
Logging instance
protected Map
parameters
The parameters for this multipart request
protected HttpServletRequest
request
The underlying HttpServletRequest

Constructor Summary

MultipartRequestWrapper(HttpServletRequest request)

Method Summary

Object
getAttribute(String name)
Enumeration
getAttributeNames()
String
getAuthType()
String
getCharacterEncoding()
int
getContentLength()
String
getContentType()
String
getContextPath()
Cookie[]
getCookies()
long
getDateHeader(String name)
String
getHeader(String name)
Enumeration
getHeaderNames()
Enumeration
getHeaders(String name)
ServletInputStream
getInputStream()
int
getIntHeader(String name)
String
getLocalAddr()
Use Reflection to invoke Servlet 2.4 getLocalAddr method on the wrapped Request.
String
getLocalName()
Use Reflection to invoke Servlet 2.4 getLocalName method on the wrapped Request.
int
getLocalPort()
Use Reflection to invoke Servlet 2.4 getLocalPort method on the wrapped Request.
Locale
getLocale()
Enumeration
getLocales()
String
getMethod()
String
getParameter(String name)
Attempts to get a parameter for this request.
Map
getParameterMap()
Implements the Servlet 2.3 getParameterMap method.
Enumeration
getParameterNames()
Returns the names of the parameters for this request.
String[]
getParameterValues(String name)
String
getPathInfo()
String
getPathTranslated()
String
getProtocol()
String
getQueryString()
BufferedReader
getReader()
String
getRealPath(String path)
String
getRemoteAddr()
String
getRemoteHost()
int
getRemotePort()
Use Reflection to invoke Servlet 2.4 getRemotePort method on the wrapped Request.
String
getRemoteUser()
HttpServletRequest
getRequest()
Returns the underlying HttpServletRequest for this wrapper
RequestDispatcher
getRequestDispatcher(String path)
String
getRequestURI()
StringBuffer
getRequestURL()
Use Reflection to invoke Servlet 2.3 getRequestURL method on the wrapped Request.
String
getRequestedSessionId()
String
getScheme()
String
getServerName()
int
getServerPort()
String
getServletPath()
HttpSession
getSession()
HttpSession
getSession(boolean create)
Principal
getUserPrincipal()
private Object
invokeRequestMethod(String name, Object[] args)
Convenience method which uses reflection to invoke a method on the Request.
boolean
isRequestedSessionIdFromCookie()
Use Reflection to invoke Servlet 2.3 isRequestedSessionIdFromCookie method on the wrapped Request.
boolean
isRequestedSessionIdFromURL()
boolean
isRequestedSessionIdFromUrl()
boolean
isRequestedSessionIdValid()
boolean
isSecure()
boolean
isUserInRole(String user)
void
removeAttribute(String name)
void
setAttribute(String name, Object o)
void
setCharacterEncoding(String encoding)
Use Reflection to invoke Servlet 2.3 setCharacterEncoding method on the wrapped Request.
void
setParameter(String name, String value)
Sets a parameter for this request.

Field Details

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 Details

MultipartRequestWrapper

public MultipartRequestWrapper(HttpServletRequest request)

Method Details

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()
            throws IOException

getIntHeader

public int getIntHeader(String name)

getLocalAddr

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

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.

getLocale

public Locale getLocale()

getLocales

public Enumeration getLocales()

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()
            throws IOException

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)

getRequestURI

public String getRequestURI()

getRequestURL

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

getRequestedSessionId

public String getRequestedSessionId()

getScheme

public String getScheme()

getServerName

public String getServerName()

getServerPort

public int getServerPort()

getServletPath

public String getServletPath()

getSession

public HttpSession getSession()

getSession

public HttpSession getSession(boolean create)

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-2007 - The Apache Software Foundation