try {
// Parse the incoming multipart form data. This may throw
// an IllegalArgumentException if the incoming data is not
// multipart/form data.
MultipartRequest req = new MultipartRequest
(new PrintWriter(System.out), contentType, contentLength,
inStream, MultipartRequest.MAX_READ_BYTES);
// copy the name/value pairs from the request into our
// list of parameters.
Enumeration parameterNames = req.getParameterNames();
while (parameterNames.hasMoreElements()) {
String name = (String) parameterNames.nextElement();
Enumeration values = req.getURLParameters(name);
while (values.hasMoreElements())
putParam(name, (String) values.nextElement());
}
// fetch all the files read, and store them into our
// parameters map.
parameterNames = req.getFileParameterNames();
while (parameterNames.hasMoreElements()) {
String name = (String) parameterNames.nextElement();
parameters.put(name, req.getFileSystemName(name));
parameters.put
(name + "_SIZE",
req.getFileParameter(name, MultipartRequest.SIZE));
parameters.put
(name + "_TYPE",
req.getFileParameter(name, MultipartRequest.CONTENT_TYPE));
parameters.put
(name + "_CONTENTS",
req.getFileParameter(name, MultipartRequest.CONTENTS));
}
} catch (IllegalArgumentException iae) {
parseFormData();
}