How can I read parameters from a multipart/form-data upload form?

Sean Sullivan

[That is, given the form:

<FORM ACTION="/servlet/FooServlet" 
      ENCTYPE="multipart/form-data"
      METHOD=POST>

What is your name? <INPUT TYPE=TEXT NAME='submitter'><br>

What file are you sending? &lt;INPUT TYPE=FILE NAME=secretDocument><br>

<input type="submit" value=Submit><br>

</FORM>
I cannot read the submitter using request.getParameter("submitter") (it returns null). ]
Situation:

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

Solutions:

Solution A:

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

Solution B:

1. download http://jakarta.apache.org/commons/sandbox/fileupload/
2. invoke readHeaders() in 
org.apache.commons.fileupload.MultipartStream

Solution C:

1. download http://users.boone.net/wbrameld/multipartformdata/
2. invoke getParameter on 
com.bigfoot.bugar.servlet.http.MultipartFormData

Solution D:

Use Struts. Struts 1.1 handles this automatically.
0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact