title: how can I clean and sanitize a url submitted by a user for redisplay in java?
body: <p>I want a user to be able to submit a url, and then display that url to other users as a link.</p>
  
  <p>If I naively redisplay what the user submitted, I leave myself open to urls like </p>
  
  <pre><code>http://somesite.com' &gt;&lt;script&gt;[any javacscript in here]&lt;/script&gt;
  </code></pre>
  
  <p>that when I redisplay it to other users will do something nasty, or at least something that makes me look unprofessional for not preventing it.</p>
  
  <p>Is there a library, preferably in java, that will clean a url so that it retains all valid urls but weeds out any exploits/tomfoolery?</p>
  
  <p>Thanks!</p>