Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to get all parameter's values from request when using multipart / form-data?

 
Fernando Dominguez
Ranch Hand
Posts: 104
Debian Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.
I’m retrieving vales from parameters in a multipart/form –data.
There is no problem when a parameter has only one value, but when a parameter has more than one value I 'm only able to get the first value.
Any idea?
Thanks.
 
Chiranjeevi Kanthraj
Ranch Hand
Posts: 290
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you tell me which parameter is having more then one value?

add the code snipet will be helpfull
 
Fernando Dominguez
Ranch Hand
Posts: 104
Debian Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello.
There is no problem in retrieving neither the file nor the form data, but when a form parameter comes with more than one value for example:
<input type="hidden" name="param1" value="A">
<input type="hidden" name="param1" value="B">

I'm only able to pick up the A

Thanks.
 
Chiranjeevi Kanthraj
Ranch Hand
Posts: 290
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if you have same name for the both input tags we get only only the first value.

i suggest give different name for input tags
 
Maneesh Godbole
Saloon Keeper
Posts: 11021
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check the API docs to see what getParameterValues(java.lang.String name) returns!
 
Fernando Dominguez
Ranch Hand
Posts: 104
Debian Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I' m afraid neither getParameter nor getParameterValues work with multipat / form-data.
This kind of form needs different treatment.
Thanks
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64629
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which API are you using to handle the multi-part form?
 
Anil Kumar Goud
Greenhorn
Posts: 12
Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Fernando Dominguez,

The form data fields must contain unique names, or else when you access form data values you will get only top level values.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64629
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anil Kumar Goud wrote:The form data fields must contain unique names, or else when you access form data values you will get only top level values.

That is not correct. It is perfectly valid for form to contain multiple elements with the same name, and all are submitted to the server. How the values are obtained is a matter of how the library being used parses the request body.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic