android - using apache HttpClient
<p>I am trying to call a servlet in Tomcat running on local from android app. I am not sure if it is reaching the servlet, because I don't see any system printout from the servlet. When I hit the url on the browser, I see something, but not from android app.</p>

<p>I have this in my AndroidManifest.xml</p>

<pre><code>&lt;uses-permission android:name="android.permission.INTERNET"&gt;&lt;/uses-permission&gt;
</code></pre>

<p>Here is my code.</p>

<pre><code>            HttpClient client = new DefaultHttpClient();
        HttpPost method = new HttpPost("http://192.168.1.6:8080/sampleweb/request");

        List&lt;BasicNameValuePair&gt; nameValuePairs = new ArrayList&lt;BasicNameValuePair&gt;();
        nameValuePairs.add(new BasicNameValuePair("req", xml));

        method.setEntity(new UrlEncodedFormEntity(nameValuePairs));

        HttpResponse response = (BasicHttpResponse) client.execute(method);

        InputStream ips = response.getEntity().getContent();
        BufferedReader buf = new BufferedReader(new InputStreamReader(ips, "UTF-8"));
        if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
            throw new Exception(response.getStatusLine().getReasonPhrase());
        }
        StringBuilder sb = new StringBuilder();
        String s;
        while (true) {
            s = buf.readLine();
            if (s == null || s.length() == 0)
                break;
            sb.append(s);
        }
        buf.close();
        ips.close();

        System.out.println("response="+sb.toString());

        client.getConnectionManager().shutdown();
</code></pre>
