commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@bluewin.ch
Subject RE: [httpclient] session after autentication
Date Mon, 13 Oct 2003 08:51:49 GMT
Hi Albert,

In order to be able to help I would need to see what gets sent across the
wire. Could you please have a look at our logging guide and produce the wire/debug
log of the HTTP session in question?

http://jakarta.apache.org/commons/httpclient/logging.html 

As a side note, make sure you always release connection once you are done
using HTTP methods. That may save you a lot of grief if ever decide to use
multi-threaded connection manager instead of the default one.

Cheers

Oleg


>-- Original Message --
>Reply-To: "Jakarta Commons Users List" <commons-user@jakarta.apache.org>
>From: "Albert Caramia" <a_caramia@hotmail.com>
>To: commons-user@jakarta.apache.org
>Subject: [httpclient] session after autentication 
>Date: Mon, 13 Oct 2003 10:07:25 +0200
>
>
>Hi,
>
>I need to use a http service that begin with a form with user/pass
>
>    HttpClient httpclient = new HttpClient();
>    httpclient.getHostConfiguration().setHost(server, 80, "http");
>
>    PostMethod post = new PostMethod("/new/index1.php");
>    NameValuePair[] data = {
>        new NameValuePair("username", user),
>        new NameValuePair("password", pass)
>    };
>    post.setRequestBody(data);
>    httpclient.executeMethod(post);
>    System.out.println(post.getResponseBodyAsString());
>    System.out.println("Login form post: " + 
>post.getStatusLine().toString());
>
>// until now everything is ok: the html contains
>
>// Login form post: HTTP/1.1 200 OK
>
>//  <FRAME name=AdmintopFrame src="head.htm" noResize scrolling=no>
>//  <FRAMESET border=0 frameSpacing=0 rows=*,9 frameBorder=NO cols="*">
>//    <frameset cols="175,*" frameborder="NO" border="0" framespacing="0"
>
>rows="*">
>//      <frame name="leftFrame" scrolling="NO" noresize src="sx.php">
>//      <FRAME name=mainFrame src="blank.htm">
>//    </frameset>
>
>    //now i need to take sx.php to continue, so I write:
>
>    GetMethod get = new GetMethod("/new/sx.php");
>    httpclient.executeMethod(get);
>
>    System.err.println(get.getResponseBodyAsString());
>
>but here I get the wrong page, the default page that I get if i try to 
>obtain the sx.php page without autenticating first.
>
>I try to use the sample code but the server don't send a redirect
>
>Thanks,
>Albert
>
>_________________________________________________________________
>Add photos to your e-mail with MSN 8. Get 2 months FREE*. 
>http://join.msn.com/?page=features/featuredemail
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: commons-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message