• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

request.getParameterValues() alternative for multipart data form.

 
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What are you using to parse the multipart form?
 
WeiJie Lim
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 99
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 99
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 can't take it! You are too smart for me! Here is the tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic