How can i send an Array with a HTTP Get request?
I’m Using GWT client to send the request.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
That depends on what the target server accepts. There is no definitive standard for this. See also a.o. Wikipedia: Query string:
Generally, when the target server uses a strong typed programming language like Java (Servlet), then you can just send them as multiple parameters with the same name. The API usually offers a dedicated method to obtain multiple parameter values as an array.
The
request.getParameter("foo")will also work on it, but it’ll return only the first value.And, when the target server uses a weak typed language like PHP or RoR, then you need to suffix the parameter name with braces
[]in order to trigger the language to return an array of values instead of a single value.In case you still use
foo=value1&foo=value2&foo=value3, then it’ll return only the first value.Do note that when you send
foo[]=value1&foo[]=value2&foo[]=value3to a Java Servlet, then you can still obtain them, but you’d need to use the exact parameter name including the braces.