Uploading a File with enctype=multipart/form-data and com.oreilly.servlet

I had a JSP with a form that DID use "method=POST" and DID NOT use "enctype=multipart/form-data" and itworked beautifully. - Now I need to upload a file in the same form.
I figured out how to use com.oreilly.servlet in a simple form that DID use "enctype=multipart/form-data"
But now I have tried to combine the two forms.
When I add "enctype=multipart/form-data" to the original form, all of my fields are null.

1.) I need to use "method=post" because there is too much data to include in a URL for the get method
2.) Someone said that with "enctype=multipart/form-data" that JSP/servlets do not support the use of .getParameter() or that I need to "decode the request to get at the parameters and contents" of the form
3.) I would really like to use the com.oreilly.servlet package since I already got it to work and it is so simple.

So how can I pull all of the form data out of the form using POST and "enctype=multipart/form-data"?

Thanks in Advance,
Who is Participating?
mderbinAuthor Commented:
Mr. Objects suggests that oReilly has an "implementation":
Comment from objects
this includes an implementation:

Does this mean that the oReilly package has a way of decoding the multipart POST?
I like oReilly.servlet, but there's not a lot of documentation to go along with it.

How can I use it to decode the form components?
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

why don't u use jakarta's upload component??

it is much easier than oreilly component
what problems exactly are you having with oreilly?
If you use struts and ActionForms, then programming will be easier and help will be widely available. You will also not get into problems which are trivial but waste lot of time :)
There are also other solutions which might be helpful in general. I have also listed the advantages of each.

Problem: javax.servlet.HttpServletRequest.getParameter(String) returns null when the ContentType is multipart/form-data


Solution A: (Advantage: Free Distribution & Widely used)

1. Download one of the versions of UploadFile from http://jakarta.apache.org/commo
2. Invoke parseRequest(request) on org.apache.commons.fileupload.FileUploadB
ase which returns list of org.apache.commons.fileupload.FileItem objects.
3. Invoke isFormField() on each of the FileItem objects. This determines whe
ther the file item is a form paramater or stream of uploaded file.
4. Invoke getFieldName() to get parameter name and getString() to get parame
ter value on FileItem if it's a form parameter. Invoke write(java.io.File) o
n FileItem to save the uploaded file stream to a file if the FileItem is not
 a form parameter.

Solution B (Advantage: Easy to use)

1. Download http://www.servlets.com/cos/index.html
2. Invoke getParameters() on com.oreilly.servlet.MultipartRequest

Solution C:

1. Download http://users.boone.net/wbrameld/multipartformdata/
2. Invoke getParameter on

Solution D (Restricted to those appliaction that use this framework):

Use Struts. Struts 1.1 handles this automatically.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.