This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Other Open Source Projects and the fly likes request.getParameterValues() alternative for multipart data form. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "request.getParameterValues() alternative for multipart data form." Watch "request.getParameterValues() alternative for multipart data form." New topic
Author

request.getParameterValues() alternative for multipart data form.

WeiJie Lim
Ranch Hand

Joined: Sep 05, 2012
Posts: 85
request.getParameter() and request.getParameterValues() do not work when the enctype for the form is multipart.

The alternative for getparameter() is getString() .

What is the alternative for getParamaterValues() ? I am trying to get the values of a checkbox.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61105
    
  66

What are you using to parse the multipart form?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
WeiJie Lim
Ranch Hand

Joined: Sep 05, 2012
Posts: 85
Bear Bibeault wrote:What are you using to parse the multipart form?


I am using the Apache Commons FileUpload.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61105
    
  66

Have you looked through its javadoc and tutorial for how to use it? Your answer will be found there if such a method exists.
WeiJie Lim
Ranch Hand

Joined: Sep 05, 2012
Posts: 85
Bear Bibeault wrote:Have you looked through its javadoc and tutorial for how to use it? Your answer will be found there if such a method exists.


I looked through the official user guide already, it doesn't state anything with relation to retrieving a set of array values..

Thanks for the tip, didn't thought of checking the Apache javadoc. It also seems like the apache javadoc for FileUpload doesn't have such a method.

I guess I have to send the checkbox data in a separate form then.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61105
    
  66

You've given up too easily.

While there isn't an API that returns the array of values that have the same request parameter name, they are still available. (As I recall, it's been years since I've used it), each request param will appear as a FileItem, and there will multiple file items with the same name for request parameters that appear more than once on the request.
WeiJie Lim
Ranch Hand

Joined: Sep 05, 2012
Posts: 85
Bear Bibeault wrote:You've given up too easily.

While there isn't an API that returns the array of values that have the same request parameter name, they are still available. (As I recall, it's been years since I've used it), each request param will appear as a FileItem, and there will multiple file items with the same name for request parameters that appear more than once on the request.


I thought of something like the code below. I did a check if it is a form field, and then as long as the form field name matches the name of the checkbox 'genreList' , it will keep extracting the checkbox parameters out due to the while loop.

The checkbox params are inserted into a ArrayList, and then later converted to an Array for easier processing for insertion to Database.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: request.getParameterValues() alternative for multipart data form.