title: How to get url object from response object of Rest Client
body: <p>I am trying to solve a problem   mentioned below</p>
  
  <p>Query this web service 100 times: </p>
  
  <pre><code>http://www.randomwebsite.com/cgi-bin/random.pl 
  </code></pre>
  
  <p>The response contains a short HTML document with one link inside. Query this link and store link URL, as well as the returned HTTP response codes in a suitable data structure.
  The application should output a list of all link URLs ordered by the first character of the domain name (ignore http:// and www prefixes) and also print the related HTTP Code, if it’s not 200.</p>
  
  <p>I am trying to use jersey client</p>
  
  <pre><code>Client client = Client.create();
              WebResource webResource2 = client.resource("http://www.randomwebsite.com/cgi-bin/random.pl");
  
              ClientResponse response2 = webResource2.accept("text/html").get(ClientResponse.class);
  
              System.out.println(response2);
  
              if (response2.getStatus() != 200) {
                  throw new RuntimeException("Failed : HTTP error code : " + response2.getStatus());
              }
  
              String output2 = response2.getEntity(String.class);
              System.out.println("\n============getFtoCResponse============");
              System.out.println(output2);
  
  
  GET http://www.westciv.com/ returned a response status of 200 OK
  </code></pre>
  
  <p>Now the problem is to store the URI i am not able to get the uri.How to get URI from the response object.I am able to see the random url  in response2  when its printed.But not able to get as a object to see the URL.I cannot get from client because the randomwebsite redirects to  random site.</p>