Class MultiPartRequestWrapper
java.lang.Object
jakarta.servlet.ServletRequestWrapper
jakarta.servlet.http.HttpServletRequestWrapper
org.apache.struts2.dispatcher.StrutsRequestWrapper
org.apache.struts2.dispatcher.multipart.MultiPartRequestWrapper
- All Implemented Interfaces:
- jakarta.servlet.http.HttpServletRequest,- jakarta.servlet.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 MultiPartRequest.
 
The struts.multipart.parser property should be set to jakarta for the Jakarta 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(LocalizedMessage). 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 SummaryFieldsFields inherited from interface jakarta.servlet.http.HttpServletRequestBASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH
- 
Constructor SummaryConstructorsConstructorDescriptionMultiPartRequestWrapper(MultiPartRequest multiPartRequest, jakarta.servlet.http.HttpServletRequest request, String saveDir, LocaleProvider provider) MultiPartRequestWrapper(MultiPartRequest multiPartRequest, jakarta.servlet.http.HttpServletRequest request, String saveDir, LocaleProvider provider, boolean disableRequestAttributeValueStackLookup) Process file downloads and log any errors.
- 
Method SummaryModifier and TypeMethodDescriptionprotected voidaddError(LocalizedMessage anErrorMessage) Adds an error message when it isn't already added.protected LocalizedMessagebuildErrorMessage(Throwable e, Object[] args) voidcleanUp()String[]getContentTypes(String name) Get an array of content encoding for the specified input field name or null if no content type was specified.Returns a collection of any errors generated when parsing the multipart request.String[]getFileNames(String fieldName) Get a String array of the file names for uploaded filesGet an enumeration of the parameter names for uploaded filesGet aFilefor the given input field name.String[]getFileSystemNames(String fieldName) Get the filename(s) of the file(s) uploaded for the given input field name.getParameter(String name) String[]getParameterValues(String name) booleanReturns true if any errors occured when parsing the HTTP multipart request, false otherwise.protected Enumeration<String>mergeParams(Enumeration<String> params1, Enumeration<String> params2) Merges 2 enumeration of parameters as one.protected voidsetLocale(jakarta.servlet.http.HttpServletRequest request) Methods inherited from class org.apache.struts2.dispatcher.StrutsRequestWrappergetAttributeMethods inherited from class jakarta.servlet.http.HttpServletRequestWrapperauthenticate, changeSessionId, getAuthType, getContextPath, getCookies, getDateHeader, getHeader, getHeaderNames, getHeaders, getHttpServletMapping, getIntHeader, getMethod, getPart, getParts, getPathInfo, getPathTranslated, getQueryString, getRemoteUser, getRequestedSessionId, getRequestURI, getRequestURL, getServletPath, getSession, getSession, getTrailerFields, getUserPrincipal, isRequestedSessionIdFromCookie, isRequestedSessionIdFromURL, isRequestedSessionIdValid, isTrailerFieldsReady, isUserInRole, login, logout, newPushBuilder, upgradeMethods inherited from class jakarta.servlet.ServletRequestWrappergetAsyncContext, getAttributeNames, getCharacterEncoding, getContentLength, getContentLengthLong, getContentType, getDispatcherType, getInputStream, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getProtocol, getProtocolRequestId, getReader, getRemoteAddr, getRemoteHost, getRemotePort, getRequest, getRequestDispatcher, getRequestId, getScheme, getServerName, getServerPort, getServletConnection, getServletContext, isAsyncStarted, isAsyncSupported, isSecure, isWrapperFor, isWrapperFor, removeAttribute, setAttribute, setCharacterEncoding, setRequest, startAsync, startAsyncMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface jakarta.servlet.ServletRequestgetAsyncContext, getAttributeNames, getCharacterEncoding, getContentLength, getContentLengthLong, getContentType, getDispatcherType, getInputStream, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getProtocol, getProtocolRequestId, getReader, getRemoteAddr, getRemoteHost, getRemotePort, getRequestDispatcher, getRequestId, getScheme, getServerName, getServerPort, getServletConnection, getServletContext, isAsyncStarted, isAsyncSupported, isSecure, removeAttribute, setAttribute, setCharacterEncoding, startAsync, startAsync
- 
Field Details- 
LOGprotected static final org.apache.logging.log4j.Logger LOG
 
- 
- 
Constructor Details- 
MultiPartRequestWrapperpublic MultiPartRequestWrapper(MultiPartRequest multiPartRequest, jakarta.servlet.http.HttpServletRequest request, String saveDir, LocaleProvider provider, boolean disableRequestAttributeValueStackLookup) Process file downloads and log any errors.- Parameters:
- multiPartRequest- Our MultiPartRequest object
- request- Our HttpServletRequest object
- saveDir- Target directory for any files that we save
- provider- locale provider
- disableRequestAttributeValueStackLookup- disable the request attribute value stack lookup
 
- 
MultiPartRequestWrapperpublic MultiPartRequestWrapper(MultiPartRequest multiPartRequest, jakarta.servlet.http.HttpServletRequest request, String saveDir, LocaleProvider provider) 
 
- 
- 
Method Details- 
setLocaleprotected void setLocale(jakarta.servlet.http.HttpServletRequest request) 
- 
buildErrorMessage
- 
getFileParameterNamesGet an enumeration of the parameter names for uploaded files- Returns:
- enumeration of parameter names for uploaded files
 
- 
getContentTypesGet an array of content encoding for the specified input field name or null if no content type was specified.- Parameters:
- name- input field name
- Returns:
- an array of content encoding for the specified input field name
 
- 
getFilesGet aFilefor the given input field name.- Parameters:
- fieldName- input field name
- Returns:
- a File[] object for files associated with the specified input field name
 
- 
getFileNamesGet a String array of the file names for uploaded files- Parameters:
- fieldName- Field to check for file names.
- Returns:
- a String[] of file names for uploaded files
 
- 
getFileSystemNamesGet the filename(s) of the file(s) uploaded for the given input field name. Returns null if the file is not found.- Parameters:
- fieldName- input field name
- Returns:
- the filename(s) of the file(s) uploaded for the given input field name or null if name not found.
 
- 
getParameter- Specified by:
- getParameterin interface- jakarta.servlet.ServletRequest
- Overrides:
- getParameterin class- jakarta.servlet.ServletRequestWrapper
- See Also:
- 
- ServletRequest.getParameter(String)
 
 
- 
getParameterMap- Specified by:
- getParameterMapin interface- jakarta.servlet.ServletRequest
- Overrides:
- getParameterMapin class- jakarta.servlet.ServletRequestWrapper
- See Also:
- 
- ServletRequest.getParameterMap()
 
 
- 
getParameterNames- Specified by:
- getParameterNamesin interface- jakarta.servlet.ServletRequest
- Overrides:
- getParameterNamesin class- jakarta.servlet.ServletRequestWrapper
- See Also:
- 
- ServletRequest.getParameterNames()
 
 
- 
getParameterValues- Specified by:
- getParameterValuesin interface- jakarta.servlet.ServletRequest
- Overrides:
- getParameterValuesin class- jakarta.servlet.ServletRequestWrapper
- See Also:
- 
- ServletRequest.getParameterValues(String)
 
 
- 
hasErrorspublic boolean hasErrors()Returns true if any errors occured when parsing the HTTP multipart request, false otherwise.- Returns:
- true if any errors occured when parsing the HTTP multipart request, false otherwise.
 
- 
getErrorsReturns a collection of any errors generated when parsing the multipart request.- Returns:
- the error Collection.
 
- 
addErrorAdds an error message when it isn't already added.- Parameters:
- anErrorMessage- the error message to report.
 
- 
mergeParamsMerges 2 enumeration of parameters as one.- Parameters:
- params1- the first enumeration.
- params2- the second enumeration.
- Returns:
- a single Enumeration of all elements from both Enumerations.
 
- 
cleanUppublic void cleanUp()
 
-