title: Java Servlet getParameter for a param that is a URL
body: <p>I am building a site which submits a url to a servlet for analysis purposes. On the client side, I submit the url as a parameter that is encoded. For example...</p>
  
  <pre><code>Submit: http://www.site.com
  Goes to: http://localhost/myservlet/?url=http%3A%2F%2Fwww.site.com
  </code></pre>
  
  <p>On the server side, I have my servlet request the parameter like so...</p>
  
  <pre><code>String url = request.getParameter("url");
  </code></pre>
  
  <p>What I receive is a decoded string: <a href="http://www.site.com" rel="noreferrer">http://www.site.com</a>. So far so good -- this works as expected... most of the time.</p>
  
  <p>The problem occurs when a url param contains parameters of its own...</p>
  
  <pre><code>Submit: http://www.site.com?param1=1&amp;param2=2
  Goes to: http://localhost/myservlet/?url=http%3A%2F%2Fwww.site.com%3Fparam1%3D1%26param2%3D2
  </code></pre>
  
  <p>Everything is fine on the client site, but in my servlet when I get the parameter I receive only part of the url param!</p>
  
  <pre><code>http://www.site.com?param1=1
  </code></pre>
  
  <p>It dropped the second param from my input url param! I am definitely encoding the url param before submitting it to the server... what is going on?</p>