for more details on the usage refer here
So you need to implement a MIME Parser, which identifies the binary boundary data. and use this boundary to parse the individual form contents.
So instead of re-inventing the wheel, you can use a 3rd party tool.something like Apache's FileUpload component. It has proper documentation. It is been widely used.
Originally posted by Pradeep Chandrasekharan Nair:
i am submitting data from a form using enctype=multipart/form-data. i am not able to get the value of text field using request.getParameter() method. but i am able to save the file which is uploaded. is there any other methods to get the value of text field.
There are many solutions to your problem if you are ready to embrace some libraries. The solutions and their advantages are as follows:
Solution A: (Advantage: Free Distribution & Widely used)
1. Download one of the versions of UploadFile from http://jakarta.apache.org/commons/fileupload/
2. Invoke parseRequest(request) on org.apache.commons.fileupload.FileUploadBase which returns list of org.apache.commons.fileupload.FileItem objects.
3. Invoke isFormField() on each of the FileItem objects. This determines whether the file item is a form paramater or stream of uploaded file.
4. Invoke getFieldName() to get parameter name and getString() to get parameter value on FileItem if it's a form parameter. Invoke write(java.io.File) on 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 (Restricted to those appliaction that use this framework):
Use Struts. Struts 1.1 handles this automatically.
[ November 01, 2004: Message edited by: Dharmanand Singh ]