hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mohit Anchlia <mohitanch...@gmail.com>
Subject How to set parameters
Date Wed, 20 Jul 2011 23:04:39 GMT
I have this servelet code that gets parameter on post. Something like
request.getParameter("requestType");

On the client I do this:

       List<NameValuePair> pairs = new ArrayList<NameValuePair>();

       for (String s : attrib.keySet()){    	
    	   System.out.println(s + attrib.get(s));
    	   pairs.add(new BasicNameValuePair(s, attrib.get(s)));
       }

       try {
		httppost.setEntity(new UrlEncodedFormEntity(pairs,HTTP.UTF_8));
		HttpResponse response = httpclient.execute(httppost);
        HttpEntity entity = response.getEntity();
        if (entity != null) {
            System.out.println(EntityUtils.toString(entity));
        }


attrib is name value and I name sure that it's the first parameter is
requestType and second it's value. But servlet still is not able to
get the parameter from the client. Not sure what's incorrect in above
code.

I created simple HTML form and that seem to work well.

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Mime
View raw message