将数据从jsp发送到android

将数据从jsp发送到android,android,jsp,Android,Jsp,在jsp中,插入后,我将使用以下代码向android发送成功或失败 response.setContentType("text/html"); ObjectOutputStream oos = new ObjectOutputStream(response.getOutputStream()); oos.writeObject("success"); out.print("success"); HttpClient httpclient = new DefaultHttpClient(

jsp中,插入后,我将使用以下代码向android发送成功或失败

 response.setContentType("text/html");
 ObjectOutputStream oos = new ObjectOutputStream(response.getOutputStream());
 oos.writeObject("success");
 out.print("success");
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://www.mysite.com.au/validation1.jsp");
List<NameValuePair> namevaluepairs = new ArrayList<NameValuePair>(2);
namevaluepairs.add(new BasicNameValuePair("pin",pass));
httppost.setEntity(new UrlEncodedFormEntity(namevaluepairs));
HttpResponse response = httpclient.execute(httppost);
HttpEntity rp = response.getEntity();
String origresponseText =  EntityUtils.toString(rp);
String responseText = origresponseText.substring(7, origresponseText.length());
Toast.makeText(getApplicationContext(), "Incoming data-->"+responseText, Toast.LENGTH_SHORT).show();
if(responseText.equals("success")){
// do something
}
在android中,我使用以下代码接收数据

 response.setContentType("text/html");
 ObjectOutputStream oos = new ObjectOutputStream(response.getOutputStream());
 oos.writeObject("success");
 out.print("success");
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://www.mysite.com.au/validation1.jsp");
List<NameValuePair> namevaluepairs = new ArrayList<NameValuePair>(2);
namevaluepairs.add(new BasicNameValuePair("pin",pass));
httppost.setEntity(new UrlEncodedFormEntity(namevaluepairs));
HttpResponse response = httpclient.execute(httppost);
HttpEntity rp = response.getEntity();
String origresponseText =  EntityUtils.toString(rp);
String responseText = origresponseText.substring(7, origresponseText.length());
Toast.makeText(getApplicationContext(), "Incoming data-->"+responseText, Toast.LENGTH_SHORT).show();
if(responseText.equals("success")){
// do something
}
HttpClient-HttpClient=newdefaulthttpclient();
HttpPost HttpPost=新的HttpPost(“http://www.mysite.com.au/validation1.jsp");
List namevaluepairs=新的ArrayList(2);
添加(新的BasicNameValuePair(“pin”,pass));
setEntity(新的UrlEncodedFormEntity(namevaluepairs));
HttpResponse response=httpclient.execute(httppost);
HttpEntity rp=response.getEntity();
String OrigResponsetText=EntityUtils.toString(rp);
字符串responseText=origresponseText.substring(7,origresponseText.length());
Toast.makeText(getApplicationContext(),“传入数据-->”+responseText,Toast.LENGTH_SHORT).show();
if(responseText.equals(“success”)){
//做点什么
}
使用此代码从JSP接收数据到ANDROID是否有任何缺陷


我的应用程序在我的手机上运行得很好,比如索尼xperia……但是在其他一些手机上,同一个应用程序没有响应不是所有的……有人能告诉我,日志跟踪后的原因是什么吗?你是否尝试过使用JSON将数据传输到android设备。你是在主线程上还是异步上这样做的。连接phn或模拟器,运行应用程序,然后查看logcat中的日志。先生,在模拟器中,它可以工作,在一些安卓手机中也是如此……但在一些手机中,它没有响应