File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

request.getParameterValues() alternative for multipart data form.

 
WeiJie Lim
Ranch Hand
Posts: 92
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64196
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What are you using to parse the multipart form?
 
WeiJie Lim
Ranch Hand
Posts: 92
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64196
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 92
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64196
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 92
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic