Java Passing URLConnection Parameter when query webpage
<p>I would like to carry out searches on www.domain.com.au where a number of URL parameters need to be supplied in order to get a 
successful HTTP response. However, the </p>

<pre><code>  1.  String url = "http://www.domain.com.au/"; // or www.realestate.com.au
  2.  String charset = "UTF-8";
  3.  String param1 = "Melbourne 3000 VIC"; // simple search on the web page
  4.
  5.  URLConnection connection = (URLConnection) new URL(url + "?" + param1).openConnection();
  6.  connection.setRequestProperty("Accept-Charset", charset);
  7.  connection.connect();
  8.  connection.setDoInput(true);
  9.  connection.setDoOutput(false);
 10.  connection.connect();
      .......
</code></pre>

<p>The response was a HTTP 400 error. As a result, I need your advice on the following questions to understand where the issue is 
coming from:</p>

<p>( i ) Should the parameter name be param1, or something else on the web page? If so, what is it?</p>

<p>( ii ) Is line 5 correct assuming that the name of the parameter is param1? Is it necessary to include 
       URLEncoder.encode(param1, charset) even though line 6 has already set it explicitly.</p>

<p>The above code snippet works on other simple webpage where no parameters are required.</p>

<p>Your advice would be much appreciated.</p>

<p>Thanks,</p>

<p>Jack</p>
