我正在做我的项目……现在我必须完成的任务是
1)我已经从android应用程序发送请求到tomcat服务器上的页面
2)页面获取对应用程序的请求和响应
对于客户端,我正在使用此代码
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Creating HTTP client
HttpClient httpClient = new DefaultHttpClient();
// Creating HTTP Post
HttpPost httpPost = new HttpPost(
"http://www.example.com/login");
// Building post parameters
// key and value pair
List<NameValuePair> nameValuePair = new ArrayList<NameValuePair>(2);
nameValuePair.add(new BasicNameValuePair("email", "user@gmail.com"));
nameValuePair.add(new BasicNameValuePair("message",
"Hi, trying Android HTTP post!"));
// Url Encoding the POST parameters
try {
httpPost.setEntity(new UrlEncodedFormEntity(nameValuePair));
} catch (UnsupportedEncodingException e) {
// writing error to Log
e.printStackTrace();
}
// Making HTTP Request
try {
HttpResponse response = httpClient.execute(httpPost);
// writing response to log
Log.d("Http Response:", response.toString());
} catch (ClientProtocolException e) {
// writing exception to log
e.printStackTrace();
} catch (IOException e) {
// writing exception to log
e.printStackTrace();
}
}
}
但我想知道...我如何才能在服务器端... 1) 我必须使用 .jsp 扩展名制作简单页面才能提前完成我的工作
2)请指导我进行测试
a)do i have to switch on wifi of laptop...
b)and also wifi of my android phone
c)connect phone through wifi with laptop by IP of laptop
d)then after connecting throught ip hit localhost server by..."192.168.1.23/file.jsp"