Hello,
I have an applet which POSTs data to a PHP page, and I think the code is ok. However, it doesn't redirect to that page. I need it to close the applet and redirect to posttest.php with the POST info. I did a stacktrace and nothing came up ... Here is my code:
if (f.exists())
{
overallLayout.show(cardPanel, "3"); //show scanning files, please wait
try
{
// Construct data
String data = URLEncoder.encode("key1", "UTF-8") + "=" + URLEncoder.encode("value1", "UTF-8");
data += "&" + URLEncoder.encode("key2", "UTF-8") + "=" + URLEncoder.encode("value2", "UTF-8");
// Send data
URL url = new URL("posttest.php");
URLConnection conn = url.openConnection();
conn.setDoOutput(true);
OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
wr.write(data);
wr.flush();
// Get the response
BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
while ((line = rd.readLine()) != null)
{
// Process line...
}
wr.close();
rd.close();
}
catch (Exception ex)
{
}
}
else
{
overallLayout.show(cardPanel, "2"); //show that it doesn't exist
}
Any help is appreciated!
Thank you,
- Jeff