Fish & Chips Club 4.10.0.0

hirondelle.fish.exercise.fileupload
Class FileUploadWrapper

Object
  extended by ServletRequestWrapper
      extended by HttpServletRequestWrapper
          extended by hirondelle.fish.exercise.fileupload.FileUploadWrapper
All Implemented Interfaces:
HttpServletRequest, ServletRequest

public class FileUploadWrapper
extends HttpServletRequestWrapper

Wrapper for a file upload request.

File upload requests are not handled graciously by the Servlet API. This class is used as a wrapper around the underlying file upload request, to allow it to behave much as a regular request.

This class uses the Apache Commons File Upload tool. The generous Apache License will very likely allow you to use it in your applications as well.


Field Summary
 
Fields inherited from interface HttpServletRequest
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH
 
Constructor Summary
FileUploadWrapper(HttpServletRequest aRequest)
          Constructor.
 
Method Summary
 FileItem getFileItem(String aFieldName)
          Return the FileItem of the given name.
 List<FileItem> getFileItems()
          Return a List<FileItem>, in the same order as they appear in the underlying request.
 String getParameter(String aName)
          Return the parameter value.
 Map getParameterMap()
          Return a Map<String, String[]> for all regular parameters.
 Enumeration getParameterNames()
          Return all request parameter names, for both regular controls and file upload controls.
 String[] getParameterValues(String aName)
          Return the parameter values.
 
Methods inherited from class HttpServletRequestWrapper
getAuthType, getContextPath, getCookies, getDateHeader, getHeader, getHeaderNames, getHeaders, getIntHeader, getMethod, getPathInfo, getPathTranslated, getQueryString, getRemoteUser, getRequestedSessionId, getRequestURI, getRequestURL, getServletPath, getSession, getSession, getUserPrincipal, isRequestedSessionIdFromCookie, isRequestedSessionIdFromUrl, isRequestedSessionIdFromURL, isRequestedSessionIdValid, isUserInRole
 
Methods inherited from class ServletRequestWrapper
getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentType, getInputStream, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRemotePort, getRequest, getRequestDispatcher, getScheme, getServerName, getServerPort, isSecure, removeAttribute, setAttribute, setCharacterEncoding, setRequest
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface ServletRequest
getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentType, getInputStream, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRemotePort, getRequestDispatcher, getScheme, getServerName, getServerPort, isSecure, removeAttribute, setAttribute, setCharacterEncoding
 

Constructor Detail

FileUploadWrapper

public FileUploadWrapper(HttpServletRequest aRequest)
                  throws IOException
Constructor.

Throws:
IOException
Method Detail

getParameterNames

public Enumeration getParameterNames()
Return all request parameter names, for both regular controls and file upload controls.

Returning the name of file upload controls allows checking of the returned param names versus a 'white list' of expected names. This increases security, which is especially important for file upload forms. See ApplicationFirewallImpl as well.

Does not include query params passed to request.getRequestDispatcher(String).

Specified by:
getParameterNames in interface ServletRequest
Overrides:
getParameterNames in class ServletRequestWrapper

getParameter

public String getParameter(String aName)
Return the parameter value. Applies only to regular parameters, not to file upload parameters. Includes query params passed to request.getRequestDispatcher(String).

If the parameter is not present in the underlying request, then null is returned.

If the parameter is present, but has no associated value, then an empty string is returned.

If the parameter is multivalued, return the first value that appears in the request.

Specified by:
getParameter in interface ServletRequest
Overrides:
getParameter in class ServletRequestWrapper

getParameterValues

public String[] getParameterValues(String aName)
Return the parameter values. Applies only to regular parameters, not to file upload parameters.

Does not include query params passed to request.getRequestDispatcher(String).

Specified by:
getParameterValues in interface ServletRequest
Overrides:
getParameterValues in class ServletRequestWrapper

getParameterMap

public Map getParameterMap()
Return a Map<String, String[]> for all regular parameters. Does not return any file upload paramters at all. Does not include query params passed to request.getRequestDispatcher(String).

Specified by:
getParameterMap in interface ServletRequest
Overrides:
getParameterMap in class ServletRequestWrapper

getFileItems

public List<FileItem> getFileItems()
Return a List<FileItem>, in the same order as they appear in the underlying request.


getFileItem

public FileItem getFileItem(String aFieldName)
Return the FileItem of the given name.

If the name is unknown, then return null.


Fish & Chips Club 4.10.0.0

Copyright Hirondelle Systems - Generated 2013Oct19.12.26