pose로 서버 스레드 접근 요청

class LoginThread implements Runnable{

		@Override
		public void run() {
			
			String user = userName_edit.getText().toString();
			String password = password_edit.getText().toString();
			NameValuePair nameValuePair1 = new BasicNameValuePair("user", user);
			NameValuePair nameValuePair2 = new BasicNameValuePair("password",password);
			List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
			nameValuePairs.add(nameValuePair1);
			nameValuePairs.add(nameValuePair2);

			try {
				HttpEntity httpEntity = new UrlEncodedFormEntity(nameValuePairs);
				HttpPost httpPost = new HttpPost(url);
				httpPost.setEntity(httpEntity);
				HttpClient httpClient = new DefaultHttpClient();
				InputStream inputStream = null;

				HttpResponse httpResponse = httpClient.execute(httpPost);
				httpEntity = httpResponse.getEntity();
				inputStream = httpEntity.getContent();
				BufferedReader reader = new BufferedReader(
						new InputStreamReader(inputStream));
				String result = "";
				String line = "";
				while ((line = reader.readLine()) != null) {
					result = result + line;
				}
				Log.v("result", result);

			} catch (UnsupportedEncodingException e) {
				e.printStackTrace();
				Log.v("result", 3 + "");
			} catch (ClientProtocolException e) {
				Log.v("result", 1 + "");
				e.printStackTrace();
			} catch (IOException e) {
				Log.v("result", 2 + "");
				e.printStackTrace();
			}

			
		}
		
	}

그중 URL은http://192.168.1.110:8080/OTOPE/servlet/LoginInfo

좋은 웹페이지 즐겨찾기