how i supplement query parameters getmethod (using java commons-httpclient)?


using apache's commons-httpclient java, what's best proceed supplement query parameters getmethod instance? i'm controlling postmethod, it's unequivocally straightforward:



postmethod slight = new postmethod();
method.addparameter("key", "value");


getmethod doesn't have an "addparameter" method, though. i've detected works:



getmethod slight = new getmethod("http://www.example.com/page");
method.setquerystring(new namevaluepair[] {
new namevaluepair("key", "value")
});


however, many examples i've seen presumably hard-code parameters directly url, e.g.:



getmethod slight = new getmethod("http://www.example.com/page?key=value");


or hard-code query string, e.g.:



getmethod slight = new getmethod("http://www.example.com/page");
method.setquerystring("?key=value");


is patterns preferred? since api inequality between postmethod getmethod? those httpmethodparams methods commanded used for?



Comments

Popular posts from this blog

list macos calm editors formula editors

how i practical urls indicate .aspx pages asp.net deployed an iis? (preferably but iis)

jaxb - xjc - reworking generated typesafe enum category members