title: Getting URL after a redirect using HttpClient.Execute(HttpGet)
body: <p>I have searched for a while and I am not finding a clear answer. I am trying to log into a webstie. 
  <a href="https://hrlink.healthnet.com/">https://hrlink.healthnet.com/</a>
  This website redirects to a login page that is not consitent. I have to post my login credentials to the redirected URL.</p>
  
  <p>Im am trying to code this in Java but I do not understand how to get the URL from the response. It may look a bit messy but I have it this way while I am testing.</p>
  
  <pre><code>    HttpGet httpget = new HttpGet("https://hrlink.healthnet.com/");
      HttpResponse response = httpclient.execute(httpget);HttpEntity entity = response.getEntity();
  
      String redirectURL = "";
  
      for(org.apache.http.Header header : response.getHeaders("Location")) {
          redirectURL += "Location: " + header.getValue()) + "\r\n";
          }        
  
      InputStream is;
      is = entity.getContent();
  
      BufferedReader reader = new BufferedReader(new InputStreamReader(is,"iso-8859-1"),8); 
      StringBuilder sb = new StringBuilder(); 
      String line = null; 
      while ((line = reader.readLine()) != null) { 
              sb.append(line + "\n"); 
      } 
      is.close(); 
  
      String result = sb.toString();
  </code></pre>
  
  <p>I know i get redirected because my result string shows be the actual login page but I am not able to get the new URL.</p>
  
  <p>In FireFox I am using TamperData. When I navigate to this website <a href="https://hrlink.healthnet.com/">https://hrlink.healthnet.com/</a> I have a GET with a 302 - Found and the Location of the Login Page. Then another GET to the actual Login Page</p>
  
  <p>Any help is greatly appreciated thank you.</p>