title: How to get the hostname for a server with URL like http://www.europewebsite.co.uk?
body: <p>The project i am working on have multiple instances(i.e different website) running in single code base. Based on the URL we show corresponding website. </p>
  
  <p>For example, if <code>http://www.uswebsite.com/</code> the we show US website. and if<code>http://www.cawebsite.com/</code>  will show Canadian website. The code that is written to detect this is </p>
  
  <pre><code>import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  
  String server` = httpRequest.getServerName();
  </code></pre>
  
  <p>If request is from the <code>http://www.uswebsite.com/</code> then according to above code <code>String server = uswebsite</code> so we have additional code written to pop up the corresponding site</p>
  
  <p>we  are now planning to include the European instance in the same code base and i see that the URL for the europe site is going to be  like this <a href="http://www.europewebsite.co.uk/" rel="nofollow">http://www.europewebsite.co.uk/</a>. With getServer() as above will it fetch <code>String server=europewebsite</code>. By having the .co.uk at the end will the above code still get <code>String server=europewebsite</code> or <code>String server=europewebsite.co</code> Please advise as i can't test it out this in my local.</p>