Reputation: 4594
I'm trying to do a post to a url by sending a username and a password using the post method.But the answer is unclear.
Here is how I do it:
HttpClient httpclient =new DefaultHttpClient();
HttpPost httppost=new HttpPost("http://test.res-novae.fr/xperia_orange/scripts/android_ckeck_user.php");
try{
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("id", "12345"));
nameValuePairs.add(new BasicNameValuePair("stringdata", "AndDev is Cool!"));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost);
/*Checking response*/
if(response!=null)
{
InputStream in = response.getEntity().getContent();
System.out.println("Resultat de la server:"+in);
}
}
catch(ClientProtocolException e)
{
}
catch (IOException e) {
// TODO Auto-generated catch block
}
and this is the answer from server:
Resultat de la server:org.apache.http.conn.EofSensorInputStream@44e067e0
Does anyone know what I'm doing wrong?
Upvotes: 0
Views: 815
Reputation: 42849
You are not reading the stream, but are rather looking at a String
representation of the underlying InputStream
object.
You will want to read the contents of the InputStream
. Take a look at this question for examples of how to do this.
Upvotes: 1