Results 1 to 2 of 2
  1. #1
    pouria_bayat is offline Member
    Join Date
    Mar 2011
    Posts
    4
    Rep Power
    0

    Default dohttppost error

    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:
    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;
            }
        }
    I already login to the site and I want to submitted site form so i use this cod:
    PHP Code:
    HttpURLConnection urlConnection = dohttppost(new URL("http://tv.station.ir/ab.php"), content, cookie);
    and wesite url is: tv.station.ir/ab.php
    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:
    PHP Code:
    URL ul = urlConnection.getURL();
    HttpURLConnection urlConnection2 = dohttppost(ul, Scontent, cookie);
    but confirm form does not work!!!
    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?

  2. #2
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,642
    Rep Power
    6

Similar Threads

  1. java out of memory error-heap space error
    By elsanthosh in forum NetBeans
    Replies: 4
    Last Post: 06-15-2010, 09:31 AM
  2. Replies: 1
    Last Post: 03-10-2010, 01:53 PM
  3. Replies: 1
    Last Post: 12-05-2009, 07:28 AM
  4. Replies: 1
    Last Post: 10-26-2009, 04:38 PM
  5. Replies: 3
    Last Post: 01-23-2009, 08:53 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •