aspose file tools*
The moose likes Servlets and the fly likes How to get all parameter's values from request  when using multipart / form-data? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to get all parameter Watch "How to get all parameter New topic
Author

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

Fernando Dominguez
Ranch Hand

Joined: Sep 01, 2006
Posts: 104

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

Joined: Feb 18, 2008
Posts: 289

Can you tell me which parameter is having more then one value?

add the code snipet will be helpfull


-Chiru
Fernando Dominguez
Ranch Hand

Joined: Sep 01, 2006
Posts: 104

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

Joined: Feb 18, 2008
Posts: 289

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

Joined: Jul 26, 2007
Posts: 10451
    
    8

Check the API docs to see what getParameterValues(java.lang.String name) returns!


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Fernando Dominguez
Ranch Hand

Joined: Sep 01, 2006
Posts: 104

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

Joined: Jan 10, 2002
Posts: 61414
    
  67

Which API are you using to handle the multi-part form?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Anil Kumar Goud
Greenhorn

Joined: Jul 11, 2013
Posts: 12

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

Joined: Jan 10, 2002
Posts: 61414
    
  67

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to get all parameter's values from request when using multipart / form-data?