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.
-
ExtendedRequest(HttpServletRequest)
- Creates a ExtendedRequest object.
-
ExtendedRequest(HttpServletRequest, File)
- Creates a ExtendedRequest object.
-
deleteTemporaryFiles()
- Deletes any temporary files created.
-
getAttribute(String)
-
-
getAuthType()
-
-
getBooleanParameter(String)
- Returns true when the specified parameter exists, false
otherwise.
-
getCharacterEncoding()
-
-
getContentLength()
-
-
getContentType()
-
-
getCookies()
-
-
getDateHeader(String)
-
-
getDateParameter(String)
- Returns the date value associated with the three parameters
that start with the specified prefix.
-
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.
-
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.
-
getFileParameterValues(String)
- Returns the uploaded file values of the specified parameter,
or null if the specified parameter does not exist.
-
getHeader(String)
-
-
getHeaderNames()
-
-
getInputStream()
-
-
getIntHeader(String)
-
-
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.
-
getMethod()
-
-
getParameter(String)
- Returns a string containing the lone value of the specified
parameter, or null if the parameter does not exist.
-
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.
-
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.
-
getPathInfo()
-
-
getPathTranslated()
-
-
getProtocol()
-
-
getQueryString()
-
-
getReader()
-
-
getRealPath(String)
-
-
getRemoteAddr()
-
-
getRemoteHost()
-
-
getRemoteUser()
-
-
getRequestedSessionId()
-
-
getRequestURI()
-
-
getScheme()
-
-
getServerName()
-
-
getServerPort()
-
-
getServletPath()
-
-
getSession(boolean)
-
-
isRequestedSessionIdFromCookie()
-
-
isRequestedSessionIdFromUrl()
-
-
isRequestedSessionIdValid()
-
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.
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.
deleteTemporaryFiles
public void deleteTemporaryFiles()
- Deletes any temporary files created. This method should be called when
the ExtendedRequest was created with the temporary directory option.
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.
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
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
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
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
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.
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
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
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
getAttribute
public Object getAttribute(String name)
getCharacterEncoding
public String getCharacterEncoding()
getContentLength
public int getContentLength()
getContentType
public String getContentType()
getInputStream
public ServletInputStream getInputStream() throws IOException
getProtocol
public String getProtocol()
getReader
public BufferedReader getReader() throws IOException
getRealPath
public String getRealPath(String virtualPath)
getRemoteAddr
public String getRemoteAddr()
getRemoteHost
public String getRemoteHost()
getScheme
public String getScheme()
getServerName
public String getServerName()
getServerPort
public int getServerPort()
getAuthType
public String getAuthType()
getCookies
public Cookie[] getCookies()
getDateHeader
public long getDateHeader(String name)
getHeader
public String getHeader(String name)
getHeaderNames
public Enumeration getHeaderNames()
getIntHeader
public int getIntHeader(String name)
getMethod
public String getMethod()
getPathInfo
public String getPathInfo()
getPathTranslated
public String getPathTranslated()
getQueryString
public String getQueryString()
getRemoteUser
public String getRemoteUser()
getRequestedSessionId
public String getRequestedSessionId()
getRequestURI
public String getRequestURI()
getServletPath
public String getServletPath()
getSession
public HttpSession getSession(boolean create)
isRequestedSessionIdFromCookie
public boolean isRequestedSessionIdFromCookie()
isRequestedSessionIdFromUrl
public boolean isRequestedSessionIdFromUrl()
isRequestedSessionIdValid
public boolean isRequestedSessionIdValid()
All Packages Class Hierarchy This Package Previous Next Index