title: Getting json works on localhost and some websites, but not working on my real server
body: <p>I have an application that is getting information from my server (online), I have a version of that website in my computer (localhost),</p>
  
  <p><strong>The application is working on localhost can get the json, But I can't have access to the website that is on server.</strong></p>
  
  <blockquote>
    <p>new
    HttpAsyncTask().execute("<a href="http://alarbaeen.com/app/?a=gallery&amp;b=images&amp;c=new&amp;d=1" rel="nofollow">http://alarbaeen.com/app/?a=gallery&amp;b=images&amp;c=new&amp;d=1</a>");</p>
  </blockquote>
  
  <p><strong>HttpAsyncTask  class:</strong></p>
  
  <pre><code>private class HttpAsyncTask extends AsyncTask&lt;String, Void, String&gt; {
      @Override
      protected String doInBackground(String... urls) {
  
  
          return GET(urls[0]);
      }
      // onPostExecute displays the results of the AsyncTask.
      @Override
      protected void onPostExecute(String result) {
          Toast.makeText(getBaseContext(), "Received!", Toast.LENGTH_LONG).show();
  
  
  
  
          try {
              JSONObject json = new JSONObject(result);
              etResponse.setText(json.toString(1));
  
          } catch (Exception e) {
              // TODO: handle exception
          }
     }
  }
  
    public static String GET(String url){
          InputStream inputStream = null;
          String result = "";
          try {
  
              // create HttpClient
              HttpClient httpclient = new DefaultHttpClient();
  
              // make GET request to the given URL
              HttpResponse httpResponse = httpclient.execute(new HttpGet(url));
  
              // receive response as inputStream
              inputStream = httpResponse.getEntity().getContent();
  
              // convert inputstream to string
              if(inputStream != null)
                  result = convertInputStreamToString(inputStream);
              else
                  result = "Did not work!";
  
          } catch (Exception e) 
          {
  
          }
  
          return result;
      }
  </code></pre>
  
  <p>These are the errors:</p>
  
  <pre><code> 03-05 12:24:32.735: E/AndroidRuntime(5859): FATAL EXCEPTION: AsyncTask #1
  03-05 12:24:32.735: E/AndroidRuntime(5859): Process: com.example.testjsons22, PID: 5859
  03-05 12:24:32.735: E/AndroidRuntime(5859): java.lang.RuntimeException: An error occured while executing doInBackground()
  03-05 12:24:32.735: E/AndroidRuntime(5859):     at android.os.AsyncTask$3.done(AsyncTask.java:300)
  03-05 12:24:32.735: E/AndroidRuntime(5859):     at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
  03-05 12:24:32.735: E/AndroidRuntime(5859):     at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
  03-05 12:24:32.735: E/AndroidRuntime(5859):     at java.util.concurrent.FutureTask.run(FutureTask.java:242)
  03-05 12:24:32.735: E/AndroidRuntime(5859):     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
  03-05 12:24:32.735: E/AndroidRuntime(5859):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
  03-05 12:24:32.735: E/AndroidRuntime(5859):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
  03-05 12:24:32.735: E/AndroidRuntime(5859):     at java.lang.Thread.run(Thread.java:841)
  03-05 12:24:32.735: E/AndroidRuntime(5859): Caused by: java.lang.NullPointerException: println needs a message
  03-05 12:24:32.735: E/AndroidRuntime(5859):     at android.util.Log.println_native(Native Method)
  03-05 12:24:32.735: E/AndroidRuntime(5859):     at android.util.Log.i(Log.java:160)
  03-05 12:24:32.735: E/AndroidRuntime(5859):     at com.example.testjsons22.MainActivity.GET(MainActivity.java:77)
  03-05 12:24:32.735: E/AndroidRuntime(5859):     at com.example.testjsons22.MainActivity$HttpAsyncTask.doInBackground(MainActivity.java:108)
  03-05 12:24:32.735: E/AndroidRuntime(5859):     at com.example.testjsons22.MainActivity$HttpAsyncTask.doInBackground(MainActivity.java:1)
  03-05 12:24:32.735: E/AndroidRuntime(5859):     at android.os.AsyncTask$2.call(AsyncTask.java:288)
  03-05 12:24:32.735: E/AndroidRuntime(5859):     at java.util.concurrent.FutureTask.run(FutureTask.java:237)
  03-05 12:24:32.735: E/AndroidRuntime(5859):     ... 4 more
  </code></pre>