Save This Page
Home » struts-2.0.11.2-src » org.apache » struts2 » dispatcher » multipart » [javadoc | source]
org.apache.struts2.dispatcher.multipart
public class: MultiPartRequestWrapper [javadoc | source]
java.lang.Object
   javax.servlet.ServletRequestWrapper
      javax.servlet.http.HttpServletRequestWrapper
         org.apache.struts2.dispatcher.StrutsRequestWrapper
            org.apache.struts2.dispatcher.multipart.MultiPartRequestWrapper

All Implemented Interfaces:
    HttpServletRequest, ServletRequest

Parse a multipart request and provide a wrapper around the request. The parsing implementation used depends on the struts.multipart.parser setting. It should be set to a class which extends org.apache.struts2.dispatcher.multipart.MultiPartRequest .

The struts.multipart.parser property should be set to jakarta for the Jakarta implementation, pell for the Pell implementation and cos for the Jason Hunter implementation.

The files are uploaded when the object is instantiated. If there are any errors they are logged using #addError(String) . An action handling a multipart form should first check #hasErrors() before doing any other processing.

An alternate implementation, PellMultiPartRequest, is provided as a plugin.
Field Summary
protected static final  Log log     
 Collection errors     
 MultiPartRequest multi     
Constructor:
 public MultiPartRequestWrapper(MultiPartRequest multiPartRequest,
    HttpServletRequest request,
    String saveDir) 
    Process file downloads and log any errors.
    Parameters:
    request - Our HttpServletRequest object
    saveDir - Target directory for any files that we save
    multiPartRequest - Our MultiPartRequest object
Method from org.apache.struts2.dispatcher.multipart.MultiPartRequestWrapper Summary:
addError,   getContentTypes,   getErrors,   getFileNames,   getFileParameterNames,   getFileSystemNames,   getFiles,   getParameter,   getParameterMap,   getParameterNames,   getParameterValues,   hasErrors,   mergeParams
Methods from org.apache.struts2.dispatcher.StrutsRequestWrapper:
getAttribute
Methods from javax.servlet.http.HttpServletRequestWrapper:
getAuthType,   getContextPath,   getCookies,   getDateHeader,   getHeader,   getHeaderNames,   getHeaders,   getIntHeader,   getMethod,   getPathInfo,   getPathTranslated,   getQueryString,   getRemoteUser,   getRequestURI,   getRequestURL,   getRequestedSessionId,   getServletPath,   getSession,   getSession,   getUserPrincipal,   isRequestedSessionIdFromCookie,   isRequestedSessionIdFromURL,   isRequestedSessionIdFromUrl,   isRequestedSessionIdValid,   isUserInRole
Methods from javax.servlet.ServletRequestWrapper:
getAttribute,   getAttributeNames,   getCharacterEncoding,   getContentLength,   getContentType,   getInputStream,   getLocalAddr,   getLocalName,   getLocalPort,   getLocale,   getLocales,   getParameter,   getParameterMap,   getParameterNames,   getParameterValues,   getProtocol,   getReader,   getRealPath,   getRemoteAddr,   getRemoteHost,   getRemotePort,   getRequest,   getRequestDispatcher,   getScheme,   getServerName,   getServerPort,   isSecure,   removeAttribute,   setAttribute,   setCharacterEncoding,   setRequest
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.struts2.dispatcher.multipart.MultiPartRequestWrapper Detail:
 protected  void addError(String anErrorMessage) 
    Adds an error message.
 public String[] getContentTypes(String name) 
    Get an array of content encoding for the specified input field name or null if no content type was specified.
 public Collection getErrors() 
    Returns a collection of any errors generated when parsing the multipart request.
 public String[] getFileNames(String fieldName) 
    Get a String array of the file names for uploaded files
 public Enumeration getFileParameterNames() 
    Get an enumeration of the parameter names for uploaded files
 public String[] getFileSystemNames(String fieldName) 
    Get the filename(s) of the file(s) uploaded for the given input field name. Returns null if the file is not found.
 public File[] getFiles(String fieldName) 
 public String getParameter(String name) 
 public Map getParameterMap() 
 public Enumeration getParameterNames() 
 public String[] getParameterValues(String name) 
 public boolean hasErrors() 
    Returns true if any errors occured when parsing the HTTP multipart request, false otherwise.
 protected Enumeration mergeParams(Enumeration params1,
    Enumeration params2) 
    Merges 2 enumeration of parameters as one.