|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.devsphere.mapping.FormData | +--com.devsphere.mapping.ServletFormData
Wrapper of javax.servlet.http.HttpServletRequest
that implements
the methods of the FormData
abstract class. This class constitutes the bridge
between the mapping framework and the Servlet API. The framework's architecture
allows you to plug-in your own implementations of FormData if necessary.
Also this class adds optional support for "multipart/form-data".
The Servlet API does not support the "multipart/form-data"
encoding type,
which is necessary for file uploading. The ServletFormData
class can parse the input stream of the wrapped javax.servlet.http.HttpServletRequest
to get a parameter set that includes string, string arrays, FileBean
objects and
FileBean
arrays.
The used "multipart/form-data"
parser is provided by JavaMail
and it wasn't designed for uploading large files. The uploaded files are
decoded and their content is kept in memory. Therefore, the file-uploading feature
should be used only when reasonable amounts of data need to be transferred
for in-memory processing.
To enable the "multipart/form-data"
parsing, you must use the constructor of
ServletFormData
that accepts two parameters, pass a HttpServletRequest
object
whose content-type
starts with "multipart/form-data"
and the second parameter
(allowMultipart
) must be true. If these conditions aren't met the multipart parser isn't enabled,
the getParameter*()
methods are delegated to the HttpServletRequest
object
and the getFileParameter*()
methods return null
(or an empty enumeration in the
case of getFileParameterNames()
).
FormData
Constructor Summary | |
ServletFormData(javax.servlet.http.HttpServletRequest request)
Creates the wrapper of a servlet request. |
|
ServletFormData(javax.servlet.http.HttpServletRequest request,
boolean allowMultipart)
Creates the wrapper of a servlet request. |
Method Summary | |
FileBean |
getFileParameter(java.lang.String name)
Gets the value of a file parameter as a FileBean ,
or null if the parameter is missing or is not an uploaded file. |
java.util.Enumeration |
getFileParameterNames()
Gets an Enumeration of String objects,
containing the names of the file parameters. |
FileBean[] |
getFileParameterValues(java.lang.String name)
Gets the values of a file parameter as a FileBean[] ,
or null if the parameter is missing or is not a list of uploaded files. |
java.lang.String |
getParameter(java.lang.String name)
Gets the value of a request parameter as a String ,
or null if the parameter is missing or is an uploaded file. |
java.util.Enumeration |
getParameterNames()
Gets an Enumeration of String objects,
containing the names of the request parameters. |
java.lang.String[] |
getParameterValues(java.lang.String name)
Gets the values of a request parameter as a String[] ,
or null if the parameter is missing or is a list of uploaded file. |
javax.servlet.http.HttpServletRequest |
getRequest()
Gets the servlet request wrapped by this object. |
boolean |
isMultipartFormData()
Returns true if the encoding type is "multipart/form-data"
and it is allowed. |
java.lang.String |
toString()
Returns a string representation of this object containing the list of request parameters and the names of the uploaded files. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public ServletFormData(javax.servlet.http.HttpServletRequest request)
getParameterNames()
, getParameter()
and getParameterValues()
methods
are delegated to the HttpServletRequest
object.
The getFileParameterNames()
method will return an empty enumeration.
The getFileParameter()
and getFileParameterValues()
methods will return null
.request
- the servlet request.NullPointerException
- if request
is null
.public ServletFormData(javax.servlet.http.HttpServletRequest request, boolean allowMultipart) throws java.io.IOException
"multipart/form-data"
encoding type must be supported in addition to "application/x-www-form-urlencoded"
.
The multipart parser is enabled only if content-type starts with "multipart/form-data"
and allowMultipart
is true
.request
- the servlet request.allowMultipart
- true
enables the multipart parser.NullPointerException
- if request
is null
.java.io.IOException
- if the request parameters were encoded using
the multipart/form-data media type and an error occurs
during the parsing of the input stream.InternalError
- if the multipart/form-data parser isn't found.Method Detail |
public javax.servlet.http.HttpServletRequest getRequest()
public boolean isMultipartFormData()
true
if the encoding type is "multipart/form-data"
and it is allowed.public java.util.Enumeration getParameterNames()
Enumeration
of String
objects,
containing the names of the request parameters.
The parameter names of the uploaded files are not included.
The enumeration is empty if the request has no parameters
or it has only uploaded files.getParameterNames
in class FormData
public java.lang.String getParameter(java.lang.String name)
String
,
or null
if the parameter is missing or is an uploaded file.getParameter
in class FormData
name
- the name of the request parameter.NullPointerException
- if name
is null
.public java.lang.String[] getParameterValues(java.lang.String name)
String[]
,
or null
if the parameter is missing or is a list of uploaded file.getParameterValues
in class FormData
name
- the name of the request parameter.NullPointerException
- if name
is null
.public java.util.Enumeration getFileParameterNames()
Enumeration
of String
objects,
containing the names of the file parameters.
The enumeration is empty if the request has no file parameters.getFileParameterNames
in class FormData
public FileBean getFileParameter(java.lang.String name)
FileBean
,
or null
if the parameter is missing or is not an uploaded file.getFileParameter
in class FormData
name
- the name of the file parameter.NullPointerException
- if name
is null
.public FileBean[] getFileParameterValues(java.lang.String name)
FileBean[]
,
or null
if the parameter is missing or is not a list of uploaded files.getFileParameterValues
in class FormData
name
- the name of the file parameter.FileBean
array containing all of the values the parameter has.NullPointerException
- if name
is null
.public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |