title: How do I read in the XML for from java http request?
body: <p>When I perform a certain action on a web app, it performs a ajax call or something along that line that returns some data in XML format. When I click On Inspect element in the browser and click on the networks tab, I can see the XML response data that was requested. see: <a href="https://i.stack.imgur.com/OCMYG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OCMYG.png" alt="enter image description here"></a></p>
  
  <p>I tried to perform a http request in java to retrieve this XML data. Here is the java code: </p>
  
  <pre><code>private StringBuffer sendGet() {
  
      final String USER_AGENT = "Mozilla/5.0";
      final String CONTENT_LENGTH = "131";
      StringBuffer response = new StringBuffer();
      String url = "https://same as the request header";
  
      try {
          //create the http connection
          URL obj = new URL(url);
          HttpsURLConnection con = (HttpsURLConnection) obj.openConnection();
  
          con.setRequestMethod("GET");
          con.setRequestProperty("User-Agent",USER_AGENT);
          con.setRequestProperty("Content-Length",CONTENT_LENGTH);
  
          int responseCode = con.getResponseCode();
          System.out.println("Sending 'GET' request to URL " + url);
          System.out.println("Response Code:" + responseCode);
  
          //read in the get reponse
          BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
          String inputLine;
  
          while((inputLine = in.readLine()) != null) {
              response.append(inputLine.toString());
          }
  
          //close input stream
          in.close();
  
          System.out.println("response is: " + response);
  
      } catch (MalformedURLException e) {
          e.printStackTrace();
  
      } catch (IOException e) {
          e.printStackTrace();
      }
  
      return response;
  }
  </code></pre>
  
  <p>For the URL I am creating a http request, I am using the exact same request URL in the ajax calls header. see:<a href="https://i.stack.imgur.com/P4TJO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/P4TJO.png" alt="enter image description here"></a></p>
  
  <p>When I perform the GET request, I received a response code of 200 which I assume the request was successful, but on my log it displays no XML even though I try to print it out. The log displayed this:</p>
  
  <pre><code>Sending 'GET' request to URL https:"blah blah blah"
  Response Code:200
  response is: 
  </code></pre>
  
  <p>I should also note that when I try to go to the request URL directly on the browser it's just a blank white page.</p>
  
  <p>When I use a request URL that contains a webpage, the http request returns all the html and js in the DOM. But the request URL I was trying to use which is just a blank page returns a blank response to me even though there are suspose to be some xml data. What am I doing wrong? Why is it that I cannot retrieve and display the XML? Do I need to parse the XML before it can be displayed?</p>