@Override
public void onClick(View v) {
// TODO Auto-generated method stub
// TODO Auto-generated method stub
String email = ((EditText)findViewById(R.id.InputId)).getText().toString();
String password = ((EditText)findViewById(R.id.InputPw)).getText().toString();

try {
String result = sendData(email, password);
Log.d("JSP", result);
if(result.equals("OK")){
Intent intent = new Intent(SpaceOpera.this, Galaxy.class);
startActivity(intent);
} else {
Intent intent = new Intent(SpaceOpera.this, Galaxy.class);
startActivity(intent);
}
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private String sendData(String email, String pw) throws ClientProtocolException, IOException{
HttpPost request = makeHttpPost(email, pw, "http://125.129.121.181:8026/sqltest.jsp");
HttpClient client = new DefaultHttpClient();
ResponseHandler<String> reshandler = new BasicResponseHandler();
String result = client.execute(request, reshandler);
return result;
}
private HttpPost makeHttpPost(String email, String pw, String url){
HttpPost request = new HttpPost(url);
ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("email", email ));
nameValuePairs.add(new BasicNameValuePair("password", pw ));
request.setEntity(makeEntity(nameValuePairs));
return request;
}
private HttpEntity makeEntity(ArrayList<NameValuePair> nameValue){
HttpEntity result = null;
try{
result = new UrlEncodedFormEntity(nameValue);
} catch (UnsupportedEncodingException e){
e.printStackTrace();
}
return result;
}