Emulating HTTP POST via httpclient 3.x for multi options

Posted by Frankie Ribery on Stack Overflow See other posts from Stack Overflow or by Frankie Ribery
Published on 2010-04-28T15:11:55Z Indexed on 2010/04/28 15:23 UTC
Read the original article Hit count: 332

Filed under:
|
|
|

I want to emulate a HTTP POST using application/x-www-form-urlencoded encoding to send a option group that allows multiple selections.

<select name="groups" multiple="multiple" size="4">
    <option value="2">Administration</option>
    <option value="1">General</option>
</select>

Does adding 2 NameValuePairs (NVP) with the same name work ? My serverside log shows that only the first NVP was received.

e.g

PostMethod method = ...;
NameValuePair[] nvpairs = {
    new NameValuePair( "groups", "2" );
    new NameValuePair( "groups", "1" );
};
method.addParameter( nvpairs );

Only the groups=1 parameter was received. Thanks

© Stack Overflow or respective owner

Related posts about java

Related posts about httpclient