'httpPost'에 해당되는 글 1

  1. 2013.08.30 httpPost방식으로 웹서버로 데이터 전송하기 1

펌 OK (출처 표시), 상업적 이용 NO, 컨텐츠 변경 NO

퍼미션은 INTERNET



public void DataSend() {

try{

url = new URI("http://192.168.0.20:8080/testWebapp/Receive.jsp");

new Thread() {

public void run() {

try {

HttpClient httpclient = new DefaultHttpClient();

HttpPost httpPost = new HttpPost(url);

ArrayList<BasicNameValuePair> nameValuePairs = new ArrayList<BasicNameValuePair>();

nameValuePairs.add(new BasicNameValuePair("mark_id", sendMarkId));

nameValuePairs.add(new BasicNameValuePair("store_name", sendName));

nameValuePairs.add(new BasicNameValuePair("latitude", sendLat));

nameValuePairs.add(new BasicNameValuePair("longitude", sendLng));

nameValuePairs.add(new BasicNameValuePair("comments", sendTip));

nameValuePairs.add(new BasicNameValuePair("kind", sendKind));

httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs, "utf-8"));

httpclient.execute(httpPost);

} catch (Exception e) {

e.printStackTrace();

}

}

}.start();

}catch(Exception e){

Log.e("fureun",e.toString());

}

}