Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2008
    Posts
    64
    Rep Power
    0

    Default Post Method in java.net

    I’m using a POST method in java.net. Below are my code snippets.

    Java Code:
     
    String username = "Freddiemaize"; 
    String password = "*******"; 
    String loginDetails = "user_login="+ username +"&user_pass=" + password;
    Java Code:
     
    URL wordpressLogin = new URL( " http://freddiemaize.wordpress.com/wp-login.php /" ); 
    HttpURLConnection HTTP = ( HttpURLConnection ) wordpressLogin.openConnection();
    Java Code:
     
    HTTP.setRequestMethod( "POST" ); 
    HTTP.setRequestProperty( "Content-Length", "" + Integer.toString(loginDetails.getBytes().length ) ); 
    HTTP.setRequestProperty( "Content-Type", "application/x-www-form-urlencoded" );
    Java Code:
     
    DataOutputStream printOut = new DataOutputStream( HTTP.getOutputStream() ); 
    printOut.writeBytes(loginDetails);
    Java Code:
     
    System.out.println("getHeaderFields - "+HTTP.getHeaderFields().toString()); 
    System.out.println("getRequestMethod - "+HTTP.getRequestMethod()); 
    System.out.println("getRequestMethod - "+HTTP.getResponseCode()); 
    System.out.println("getURL - "+HTTP.getURL().toString()); 
    in.close();
    However the results are not as expected. Below is my output,

    getRequestMethod - GET
    getRequestMethod - 200
    getURL - http*://freddiemaize.wordpress.com/wp-login.php?action=auth&redirect_to=
    http%3A%2F%2Ffreddiemaize.wordpress.com%2Fwp-admin%2F
    Well, I expect a 302 response code and the method to be POST and the url to be http*://freddiemaize.wordpress.com/wp-admin/ which is my landing page.

    My doubt is, is my expectation wrong or my expectation is correct but there is a bug in my code. Please advice. Thank you very much.

    Freddie

  2. #2
    zanussi is offline Member
    Join Date
    Feb 2009
    Location
    United Kingdom
    Posts
    1
    Rep Power
    0

    Default Мировой финансовый кризис

    В нынешней ситуации большинство тем отходят на второй план. Интересно, как мы будем жить, если доллар рухнет?

  3. #3
    bellamind is offline Member
    Join Date
    Feb 2009
    Posts
    1
    Rep Power
    0

    Default Кто виноват в кризисе

    Кризис, говорят, в марте усилится. Хотелось бы знать, кто затеял все это
    и как вообще мы докатились до такой жизни.

Similar Threads

  1. First post ever
    By pbpersson in forum Introductions
    Replies: 4
    Last Post: 08-16-2008, 06:30 AM
  2. First post as per request
    By happyknappy in forum Introductions
    Replies: 3
    Last Post: 07-30-2008, 02:33 AM
  3. The first post and first question
    By m_kaleia in forum New To Java
    Replies: 8
    Last Post: 07-19-2008, 07:27 PM
  4. post info to a webpage
    By kmp in forum Networking
    Replies: 1
    Last Post: 03-22-2008, 03:20 AM
  5. Replies: 1
    Last Post: 07-14-2007, 06:15 PM

Posting Permissions

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