私は自分のプロジェクトに取り組んでいます...今私が達成しなければならないことはそれです
1)私はアンドロイドアプリケーションから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();
}
}
}
しかし、私は知りたい...どうすればサーバー側にドンすることができますか ...
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"