URLConnect - writing data to 3 text fields on website
<p>My program should connect to a website's login form, where I get my data from a database(username &amp; password) and it should input that into the text fields within the login form.</p>

<p>This is the code i have so far, but doesnt seem to work.</p>

<pre><code>try {
URL url = new URL( "http://www.clubvip.co.za/Login.aspx" );
HttpURLConnection hConnection = (HttpURLConnection)url.openConnection();
hConnection.setDoOutput( true );
hConnection.setRequestMethod("POST");
PrintStream ps = new PrintStream( hConnection.getOutputStream() );
ps.print("ctl00_ContentPlaceHolder1_CellNumberRadText_text=username&amp;amp;ctl00_ContentPlaceHolder1_PasswordRadText_text=password&amp;amp;
ps.close();
hConnection.connect();

if( HttpURLConnection.HTTP_OK == hConnection.getResponseCode() )
{
InputStream is = hConnection.getInputStream();
OutputStream os = new FileOutputStream("output.html");
int data;
while((data=is.read()) != -1)
{
os.write(data);
}
is.close();
System.out.println("is close");
os.close();
hConnection.disconnect();
}

} catch(Exception ex)
{
ex.printStackTrace();
}
</code></pre>
