http post - How to get only string from HTTPResponse RestApi Android -


i have tried code snippet response android using httpresponse

string s=""; try {      httpclient httpclient=new defaulthttpclient();     httppost httppost=new httppost("http://10.0.0.8:7777/httppostservlet/servlet/login");     list<namevaluepair> list=new arraylist<namevaluepair>();     list.add(new basicnamevaluepair("uname", valuse[0]));     list.add(new basicnamevaluepair("pwd",valuse[1]));     httppost.setentity(new urlencodedformentity(list));     httpresponse httpresponse=  httpclient.execute(httppost);     httpentity httpentity=httpresponse.getentity();     string responsestr = entityutils.tostring(httpresponse.getentity());     s= readresponse(httpresponse);     system.err.println("response: " + s +"/// "+ "another resposn :: "+responsestr ); } catch(exception exception)    {      system.err.println("exception: " + exception.getmessage()); } 

also have tried method reponse

public string readresponse(httpresponse res) {      inputstream is=null;     string return_text="";     string result="";     try {          is=res.getentity().getcontent();         bufferedreader bufferedreader=new bufferedreader(new inputstreamreader(is));         string line="";         stringbuffer sb=new stringbuffer();         httpentity entity = res.getentity();         while ((line=bufferedreader.readline())!=null) {              sb.append(line);         }         return_text=sb.tostring();         result = entityutils.tostring(entity).tostring();     } catch (exception e) {}     return result; } 

i getting response follows

<?xml version="1.0" encoding="utf-8"?><string xmlns="http://23.253.164.20:8096/">unsuccessfull</string>

i want unsuccessfull or successful

do have change in server side or done client side plain text

what need 1 more line - when become httpresponse whole html response site, need remove tags , single line string responseastext = android.text.html.fromhtml(result).tostring() result string repsonse httpresponse. can add line @ end of both codes have provided.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -