title: Java JSP get hostname (url) and then redirect if not
body: <p>I'm not a jsp developer but i would like to make a small adjustment to a jsp page in some open source software i have. </p>
  
  <p>All i want to do is find out what url i used to get to the page, let's say  <a href="https://old.example.com" rel="nofollow">https://old.example.com</a>, and if i did then i would like to redirect the user to <a href="https://new.example.com" rel="nofollow">https://new.example.com</a>, but i don't want to get in a redirect loop obviously...</p>
  
  <p>how would i go about this ...</p>