从jsp发送数据到android

时间:2013-04-26 17:18:22

标签: android jsp

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

 response.setContentType("text/html");
 ObjectOutputStream oos = new ObjectOutputStream(response.getOutputStream());
 oos.writeObject("success");
 out.print("success");

android 中我使用以下代码

接收数据
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
}

使用此代码从JSP接收DATAS是否有任何缺陷

我的应用程序在我的手机中完美运行,即sony xperia ....但同样的应用程序在其他一些手机中没有响应并不是全部....有人可以告诉我背后的原因是什么

0 个答案:

没有答案