title: how do I encode CGI arguments when constructing a java URL for eventual HTTP GET using openConnection()
body: <p>I need to use java to do an HTTP GET to a CGI and pass it some parameters, one of which is itself a URL with some embedded CGI arguments.</p>
  
  <p>I tried </p>
  
  <pre><code>String cgiArgs="client="+clientAddr+"&amp;tag="+sessionId+"&amp;rates="+ratesString
      +"&amp;callbackURL="+URLEncoder.encode(callbackURL);
  if (null != debugGateway)
      cgiArgs += "&amp;gateway=" +debugGateway; // for debugging
  URI u_ = new URI("http", null, "scimitar", 3000, "/igmpcgi/allocateAuxiliaryStream",
          cgiArgs, null);
  URL u = u_.toURL();
  URLConnection conn = u.openConnection();
  </code></pre>
  
  <p>Unfortunately, the <code>java.net.URLEncoder.encode()</code> method quotes things in such a way that then end up getting quoted again during <code>openConnection()</code>.  </p>
  
  <p>What is the proper java way to construct a CGI argument string when some of the key=value pairs include string values that themselves have ?,&amp;, and = characters ?</p>