I upgraded and it worked. On Wed, Jul 20, 2011 at 2:02 PM, Mohit Anchlia <[email protected]> wrote: > I am using 4.0 and have this code. I think I am doing something wrong > but not sure what. My program hangs when executing new > DefaultHttpClient() > > On server side I use request.getParameter() that I set using setEntity. > > public static boolean doPost(String uri, Map<String,String> attrib){ > > boolean result=false; > HttpClient httpclient = new DefaultHttpClient(); > System.out.println("Here 1"); > > HttpPost httppost = new HttpPost(uri); > System.out.println("Here 2"); > > List pairs = new ArrayList(); > System.out.println("Here 1"); > for (String s : attrib.keySet()){ > pairs.add(new BasicNameValuePair(s, attrib.get(s))); > } > > try { > httppost.setEntity(new UrlEncodedFormEntity(pairs)); > HttpResponse response = httpclient.execute(httppost); > if (200 != response.getStatusLine().getStatusCode()){ > log.info("Error " + > response.getStatusLine().getReasonPhrase() + " > " + response.getStatusLine().getStatusCode()); > result=false; > } > } catch (ClientProtocolException e) { > // TODO Auto-generated catch block > e.printStackTrace(); > } catch (IOException e) { > // TODO Auto-generated catch block > e.printStackTrace(); > }finally{ > httpclient.getConnectionManager().shutdown(); > } > return result; > } >
--------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
