title: How to check programatically if url of page is redirecting?
body: <p>I am trying to extract the content of a webpage A. Using groovy I've tried the following</p>
  
  <pre><code>......
  String urlStr = "url-of-webpage-A"
  String pageText = urlStr.toURL().text
  //println pageText
  .....
  </code></pre>
  
  <p>The above code retrieves the text of webPage A as long as it doesn't redirect to an other webpage B. If A redirects to B, the page content of webPage B is retrieved in the pageText variable. Is there a way to code and check if webPage A is redirecting to an other webpage (in groovy or java)?</p>
  
  <p>PS: The above piece of code is not a part of server side logic. I am executing it on the client side within the scope of a desktop appilcation.</p>