hi;
Some time ago I've started writing a program that the ability to login to the website and submitting website form to be had but i got some error i use this cod:
I already login to the site and I want to submitted site form so i use this cod:PHP Code:
public HttpURLConnection dohttppost(URL targetUrl, String content, String cookie) throws IOException {
HttpURLConnection urlConnection = null;
HttpURLConnection urlConnection2 = null;
DataOutputStream dataOutputStream = null;
DataOutputStream dataOutputStream2 = null;
try {
urlConnection = (HttpURLConnection) (targetUrl.openConnection());
urlConnection.setDoInput(true);
urlConnection.setDoOutput(true);
urlConnection.setRequestProperty("Cookie", cookie);
urlConnection.setRequestProperty("Content-Type", POST_CONTENT_TYPE);
urlConnection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3");
urlConnection.setRequestProperty("Connection", "Keep-Alive");
HttpURLConnection.setFollowRedirects(true);
urlConnection.setRequestMethod("POST");
dataOutputStream = new DataOutputStream(urlConnection.getOutputStream());
dataOutputStream.writeBytes(content);
dataOutputStream.flush();
dataOutputStream.close();
return urlConnection;
} catch (IOException ioException) {
System.out.println("I/O problems while trying to do a HTTP post.");
ioException.printStackTrace();
if (dataOutputStream != null) {
try {
dataOutputStream.close();
} catch (Throwable ignore) {
}
}
if (urlConnection != null) {
urlConnection.disconnect();
}
throw ioException;
}
}
and wesite url is: tv.station.ir/ab.phpPHP Code:
HttpURLConnection urlConnection = dohttppost(new URL("http://tv.station.ir/ab.php"), content, cookie);
Website forms like the following picture:
When I'm using the dohttppost method of operation Does correct but that page refers to another page form to Approving or final accepting like the following:
wesite url refers to: tv.station.ir/ab.php
again and form like the following picture:
now when i use this cod i got error:
but confirm form does not work!!!PHP Code:
URL ul = urlConnection.getURL();
HttpURLConnection urlConnection2 = dohttppost(ul, Scontent, cookie);
and i can not send forms good because the forms has confirm form and refer to another page.
plz help me what should i do?