title: Converting anchor tag with relative URL to absolute URL in HTML content using Java
body: <p>The situation:</p>
  
  <p>On server A we want to display content from server B in line on server A.</p>
  
  <p>The problem:</p>
  
  <p>Some of the hyperlinks in the content on server B are relative to server B which makes them invalid when displayed on server A. </p>
  
  <p>Given a block of HTML code that contains anchor tags like the following </p>
  
  <p><code>&lt;a href="/something/somwhere.html"&gt;Somewhere&lt;/a&gt;</code> </p>
  
  <p>what would be the most efficient way to convert them to </p>
  
  <p><code>&lt;a href="http://server-b.com/something/somewhere.html"&gt;Somewhere&lt;/a&gt;</code></p>
  
  <p>There can be multiple anchor tags in the content, the one catch is that some might be absolute and I want to leave those as they are, I only want to prepend the domain of server B to the relative URLs</p>