All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class nl.nmg.servlet.ExtendedRequest

java.lang.Object
   |
   +----nl.nmg.servlet.ExtendedRequest

public class ExtendedRequest
extends Object
implements HttpServletRequest
ExtendedRequest is a wrapper object around an HttpServletRequest object, providing multipart/form-data support and convenient getXXXParameter functions.

When an ExtendedRequest object is created, and the request content-type is multipart/form-data, the data is parsed, and subsequent calls to ExtendedRequest.getParameter() work as expected. Use getFileParameter() to retrieve file upload data.

Additionally ExtendedRequest provides convenient retrieval functions like getBooleanParameter, getIntParameter and getDateParameter.

All other methods just pass data on to the HttpServletRequest object. This only works with JSDK2.0. You may need to add or remove a number of dummy functions for other versions of the JSDK.


Constructor Index

 o ExtendedRequest(HttpServletRequest)
Creates a ExtendedRequest object.
 o ExtendedRequest(HttpServletRequest, File)
Creates a ExtendedRequest object.

Method Index

 o deleteTemporaryFiles()
Deletes any temporary files created.
 o getAttribute(String)
 o getAuthType()
 o getBooleanParameter(String)
Returns true when the specified parameter exists, false otherwise.
 o getCharacterEncoding()
 o getContentLength()
 o getContentType()
 o getCookies()
 o getDateHeader(String)
 o getDateParameter(String)
Returns the date value associated with the three parameters that start with the specified prefix.
 o getDoubleParameter(String, double)
Returns the lone value of the specified parameter converted to a double, or the specified default if the value can not be converted or the parameter does not exist.
 o getFileParameter(String)
Returns the lone uploaded file value of the specified parameter, or null if the parameter does not exists or is not an uploaded file value.
 o getFileParameterValues(String)
Returns the uploaded file values of the specified parameter, or null if the specified parameter does not exist.
 o getHeader(String)
 o getHeaderNames()
 o getInputStream()
 o getIntHeader(String)
 o getIntParameter(String, int)
Returns the lone value of the specified parameter converted to an int, or the specified default if the value can not be converted or the parameter does not exist.
 o getMethod()
 o getParameter(String)
Returns a string containing the lone value of the specified parameter, or null if the parameter does not exist.
 o getParameterNames()
Returns the parameter names for this request as an enumeration of strings, or an empty enumeration if there are no parameters or the input stream is empty.
 o getParameterValues(String)
Returns the values of the specified parameter for the request as an array of strings, or null if the named parameter does not exist.
 o getPathInfo()
 o getPathTranslated()
 o getProtocol()
 o getQueryString()
 o getReader()
 o getRealPath(String)
 o getRemoteAddr()
 o getRemoteHost()
 o getRemoteUser()
 o getRequestedSessionId()
 o getRequestURI()
 o getScheme()
 o getServerName()
 o getServerPort()
 o getServletPath()
 o getSession(boolean)
 o isRequestedSessionIdFromCookie()
 o isRequestedSessionIdFromUrl()
 o isRequestedSessionIdValid()

Constructors

 o ExtendedRequest
 public ExtendedRequest(HttpServletRequest request,
                        File tmpDir) throws IOException
Creates a ExtendedRequest object. If the input is of type multipart/form-data the input is parsed, and any uploaded file objects will be saved to a temporary directory. Remember to call deleteTemporaryFiles() when you are done, to delete these temporary files.

Parameters:
request - is the request object passed to the service(), doGet() or doPost() method.
tmpDir - is the directory that may be used to hold temporary files.
 o ExtendedRequest
 public ExtendedRequest(HttpServletRequest request) throws IOException
Creates a ExtendedRequest object. If the input is of type multipart/form-data the input is parsed, and any uploaded file objects will be saved in memory.

Parameters:
request - is the request object passed to the service(), doGet() or doPost() method.

Methods

 o deleteTemporaryFiles
 public void deleteTemporaryFiles()
Deletes any temporary files created. This method should be called when the ExtendedRequest was created with the temporary directory option.

 o getParameterNames
 public Enumeration getParameterNames()
Returns the parameter names for this request as an enumeration of strings, or an empty enumeration if there are no parameters or the input stream is empty.

 o getParameter
 public String getParameter(String name)
Returns a string containing the lone value of the specified parameter, or null if the parameter does not exist. If the value is an uploaded file, the client-side filename is returned.

Servlet writers should use this method only when they are sure that there is only one value for the parameter. If the parameter has (or could have) multiple values, servlet writers should use getParameterValues. If a multiple valued parameter name is passed as an argument, the return value is implementation dependent.

Parameters:
name - the name of the parameter whose value is required.
See Also:
getParameterValues
 o getParameterValues
 public String[] getParameterValues(String name)
Returns the values of the specified parameter for the request as an array of strings, or null if the named parameter does not exist. If any of the parameter's values are uploaded files, the client-side filenames are returned.

Parameters:
name - the name of the parameter whose value is required.
See Also:
getParameter
 o getFileParameter
 public UploadedFile getFileParameter(String name)
Returns the lone uploaded file value of the specified parameter, or null if the parameter does not exists or is not an uploaded file value.

Parameters:
name - the name of the parameter whose value is required.
See Also:
getFileParameterValues
 o getFileParameterValues
 public UploadedFile[] getFileParameterValues(String name)
Returns the uploaded file values of the specified parameter, or null if the specified parameter does not exist. The array contains null for a value that is not an uploaded file.

Parameters:
name - the name of the parameter whose value is required.
See Also:
getFileParameter
 o getBooleanParameter
 public boolean getBooleanParameter(String name)
Returns true when the specified parameter exists, false otherwise.

Parameters:
name - the name of the parameter whose value is required.
 o getIntParameter
 public int getIntParameter(String name,
                            int defaultValue)
Returns the lone value of the specified parameter converted to an int, or the specified default if the value can not be converted or the parameter does not exist.

Parameters:
name - the name of the parameter whose value is required
defaultValue - the default value to use
 o getDoubleParameter
 public double getDoubleParameter(String name,
                                  double defaultValue)
Returns the lone value of the specified parameter converted to a double, or the specified default if the value can not be converted or the parameter does not exist.

Parameters:
name - the name of the parameter whose value is required
defaultValue - the default value to use
 o getDateParameter
 public Date getDateParameter(String prefix)
Returns the date value associated with the three parameters that start with the specified prefix. The prefix is appended with "_day", "_month" and "_year" to find the day of the month, the month and the year respectivily.

The day is a number between 1 and 31 (inclusive) and the month is a number between 1 and 12 (inclusive). The year is the real year, not the year minus 1900. If the conversion failed or one of the parameters does not exist, null is returned.

Parameters:
prefix - the prefix of the parameter whose value is required
See Also:
printDateSelect
 o getAttribute
 public Object getAttribute(String name)
 o getCharacterEncoding
 public String getCharacterEncoding()
 o getContentLength
 public int getContentLength()
 o getContentType
 public String getContentType()
 o getInputStream
 public ServletInputStream getInputStream() throws IOException
 o getProtocol
 public String getProtocol()
 o getReader
 public BufferedReader getReader() throws IOException
 o getRealPath
 public String getRealPath(String virtualPath)
 o getRemoteAddr
 public String getRemoteAddr()
 o getRemoteHost
 public String getRemoteHost()
 o getScheme
 public String getScheme()
 o getServerName
 public String getServerName()
 o getServerPort
 public int getServerPort()
 o getAuthType
 public String getAuthType()
 o getCookies
 public Cookie[] getCookies()
 o getDateHeader
 public long getDateHeader(String name)
 o getHeader
 public String getHeader(String name)
 o getHeaderNames
 public Enumeration getHeaderNames()
 o getIntHeader
 public int getIntHeader(String name)
 o getMethod
 public String getMethod()
 o getPathInfo
 public String getPathInfo()
 o getPathTranslated
 public String getPathTranslated()
 o getQueryString
 public String getQueryString()
 o getRemoteUser
 public String getRemoteUser()
 o getRequestedSessionId
 public String getRequestedSessionId()
 o getRequestURI
 public String getRequestURI()
 o getServletPath
 public String getServletPath()
 o getSession
 public HttpSession getSession(boolean create)
 o isRequestedSessionIdFromCookie
 public boolean isRequestedSessionIdFromCookie()
 o isRequestedSessionIdFromUrl
 public boolean isRequestedSessionIdFromUrl()
 o isRequestedSessionIdValid
 public boolean isRequestedSessionIdValid()

All Packages  Class Hierarchy  This Package  Previous  Next  Index