0
我有一個名爲ConnectionToOracle的java web項目。我有一個名爲Sign_Up_Servlet的servlet。json在makeHttpRequest調用中爲null
所以我有以下代碼:
private static String url_sign_up_execute
= "http://10.11.201.84:8084//ConnectionToOracle/Sign_Up_Servlet";
private class GetSignUpStatus extends AsyncTask<String, Integer, String> {
ProgressDialog pDialog = new ProgressDialog(Sign_Up.this);
@Override
protected void onPreExecute() {
// TODO Auto-generated method stub
super.onPreExecute();
pDialog.setMessage("Please wait...");
pDialog.show();
}
@Override
protected void onPostExecute(String result) {
// TODO Auto-generated method stub
super.onPostExecute(result);
pDialog.dismiss();
if (json == null) {
pDialog.dismiss();
Toast.makeText(
getApplicationContext(),
"Unable to Perform Your Request.Server Is Temporarily Unreachable! Please Try Later.",
Toast.LENGTH_LONG).show();
}
else{
if(pErrorFlag.equals("N"))
Toast.makeText(getApplicationContext(),"Sign Up successfully done ", Toast.LENGTH_LONG).show();
else if(pErrorFlag.equals("Y"))
Toast.makeText(getApplicationContext(), pErrorMessage, Toast.LENGTH_LONG).show();
}
}
@Override
protected String doInBackground(String... args) {
// TODO Auto-generated method stub
List<NameValuePair> params = new ArrayList<NameValuePair>();
// params.add(new BasicNameValuePair("pDeviceId",deviceId_str));
// params.add(new BasicNameValuePair("pMobileNo",mobile_no_str));
// params.add(new BasicNameValuePair("pUserId",user_id_str));
// params.add(new BasicNameValuePair("pPassword",password_str));
// params.add(new BasicNameValuePair("pPinCode",pin_code_str));
// params.add(new BasicNameValuePair("pDeviceId","1"));
// params.add(new BasicNameValuePair("pMobileNo","1"));
// params.add(new BasicNameValuePair("pUserId","1"));
// params.add(new BasicNameValuePair("pPassword","1"));
// params.add(new BasicNameValuePair("pPinCode","1"));
//
json = jsonParser.makeHttpRequest(url_sign_up_execute, "POST", params);
// Log.d("All Login Responese: ", json.toString());
try {
if (json != null) {
jsonArray = json.getJSONArray(TAG_SIGN_UP);
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject c = jsonArray.getJSONObject(i);
pErrorFlag = c.getString(TAG_ERROR_FLAG);
pErrorMessage = c.getString(TAG_ERROR_MESSAGE) ;
}
// Log.d("error Code", errorCode);
} else {
Log.d("Server Unreachable",
"Unable to Perform Your request.Server Is Unreachable! Please Try Later.");
}
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
}
我想提出一個HTTP請求到 「http://10.11.201.84:8084//ConnectionToOracle/Sign_Up_Servlet」 的網址。但我得到json值爲空。爲什麼?我該如何解決這個錯誤?