net.jot.web
Class JOTFlowRequest

java.lang.Object
  extended by javax.servlet.ServletRequestWrapper
      extended by javax.servlet.http.HttpServletRequestWrapper
          extended by net.jot.web.JOTFlowRequest
All Implemented Interfaces:
javax.servlet.http.HttpServletRequest, javax.servlet.ServletRequest
Direct Known Subclasses:
JOTRewrittenRequest

public class JOTFlowRequest
extends javax.servlet.http.HttpServletRequestWrapper

This is a custom extension of the standard HttpServletRequestWrapper with added functionality. In particular it supports a setParameter() method that allows to overide/manipulates parameter values. It also provides basic for multipartRequest support (ie: file uploads from forms)

Author:
thibautc

Field Summary
 
Fields inherited from interface javax.servlet.http.HttpServletRequest
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH
 
Constructor Summary
JOTFlowRequest(javax.servlet.http.HttpServletRequest request)
           
 
Method Summary
 void addFile(JOTMultiPartItem item)
          Called internally by JOTMultiPartParser, if a file was uploaded from the form.
 void finalize()
          When the request is completed/terminated tries to delete the temporary multipart data (uploaded files)
 java.util.Hashtable getCustomParams()
           
 JOTMultiPartItem getFile(java.lang.String name)
          Return a file handle(JOTMultiPartItem) from the request(multipart request) for an uploaded file, which you can then save somewhere NOTE: parseMultiPartContent() MUST have been called first otherwise it will return nothing(null).
 java.lang.String getParameter(java.lang.String name)
          Overload of getParameter, to take into account our custom setRequest feature
 void parseMultiPartContent(java.lang.String tempDataFolder, long maxSize)
          Call this if you want to parse the request as a multipart content.
 void setCustomParams(java.util.Hashtable customParams)
           
 void setParameter(java.lang.String name, java.lang.String value)
          SetParameter will save the new parameter value (valid through the java request.)
 
Methods inherited from class javax.servlet.http.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 javax.servlet.ServletRequestWrapper
getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentType, getInputStream, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getParameterMap, getParameterNames, getParameterValues, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRemotePort, getRequest, getRequestDispatcher, getScheme, getServerName, getServerPort, isSecure, removeAttribute, setAttribute, setCharacterEncoding, setRequest
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.servlet.ServletRequest
getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentType, getInputStream, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getParameterMap, getParameterNames, getParameterValues, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRemotePort, getRequestDispatcher, getScheme, getServerName, getServerPort, isSecure, removeAttribute, setAttribute, setCharacterEncoding
 

Constructor Detail

JOTFlowRequest

public JOTFlowRequest(javax.servlet.http.HttpServletRequest request)
Method Detail

getCustomParams

public java.util.Hashtable getCustomParams()

setCustomParams

public void setCustomParams(java.util.Hashtable customParams)

setParameter

public void setParameter(java.lang.String name,
                         java.lang.String value)
SetParameter will save the new parameter value (valid through the java request.)

Parameters:
name -
value -

getParameter

public java.lang.String getParameter(java.lang.String name)
Overload of getParameter, to take into account our custom setRequest feature

Specified by:
getParameter in interface javax.servlet.ServletRequest
Overrides:
getParameter in class javax.servlet.ServletRequestWrapper

parseMultiPartContent

public void parseMultiPartContent(java.lang.String tempDataFolder,
                                  long maxSize)
                           throws java.lang.Exception
Call this if you want to parse the request as a multipart content. ie: data is coming from a form with enctype="multipart/form-data" Usually this is a file upload form. By default it is not done automatically for performance/security reasons. So you will want to call this method manually to parse the multipart form. This will: - add the multipart variables as request parameters, so you can read them with getParameter() - uplload the files data to a temporary folder, so you can get/save the files getFileItem().xxx()

Throws:
java.lang.Exception

finalize

public void finalize()
              throws java.lang.Throwable
When the request is completed/terminated tries to delete the temporary multipart data (uploaded files)

Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

addFile

public void addFile(JOTMultiPartItem item)
Called internally by JOTMultiPartParser, if a file was uploaded from the form.

Parameters:
item -

getFile

public JOTMultiPartItem getFile(java.lang.String name)
Return a file handle(JOTMultiPartItem) from the request(multipart request) for an uploaded file, which you can then save somewhere NOTE: parseMultiPartContent() MUST have been called first otherwise it will return nothing(null).

Parameters:
name - : the name of the file (HTML input name)
Returns:
: Handle to the uplaoded file. see javadoc of net.jot.web.multipart.JOTMultiPartParser for an example