Maybe "my" thread helps concerning the cookies:

http://marc.theaimsgroup.com/?l=jakarta-commons-user&m=102984523529696&w=2

HTH

Michael


[EMAIL PROTECTED] wrote:

> Hello to all of you!
> 
> I don't know if it is common on this mailing-list to introduce yourself as a
> new member, so I just briefly tell you that my name is Thilo, that I am from
> Germany and that I'm currently working on a project that includes logging
> into username/password-protected websites and retrieving certain information
> from there.
> I started using JDK-standard-classes (such as reader/writer/UrlConnection)
> and had some success in simulating submitting HTTP-Forms via post to
> webservers, but never could get a session-cookie. In a NG I was recommended the
> Jakarta HTTPClient, so I got the latest nightly build (I was also told that these
> were already very stable). Using parts of the examples, I established
> communication with the reverse-servlet at java.sun.com without problems.
> Secondly, I tried logging into the developer-area at java.sun.com (what I
> had already done using the standard-classes, but without being able to get the
> session-cookie). The response-code the server sends is 302, the body of the
> HTTP-Response is empty.
> Moreover, I am shown the following hint:
> --------------------------------------------------------------------
> 27.08.2002 14:14:18 org.apache.commons.logging.impl.Jdk14Logger info
> INFO: Redirect requested but followRedirects is disabled
> --------------------------------------------------------------------
> I don't really understand this, because using 'setFollowRedirects(true)', I
> have told my POST-method to follow redirects.
> At the end you can see an excerpt of my code (at this point, I - still - do
> noct handle the session cookie).
> If anybody has any idea what I am doing wrong, I'd be very pleased if he/she
> told me :-)
> 
> Thanks in advance
> 
> Thilo
> 
> 
> 
> Code-Excerpt:
> ===================================================================
> PostMethod post = new PostMethod();
>       
> post.setRequestBody(sendString);
>                       
> if ( (myURL.getPath() == null) || (myURL.getPath().length() == 0) )
> {
>       post.setPath("/");
> }
> else
> {
>       post.setPath(myURL.getPath());
> }
> 
> post.setFollowRedirects(true);
>                       
> HttpClient hc = new HttpClient();
>                       
> hc.startSession(myURL);
>                       
> int iResultCode = hc.executeMethod(post);
>                       
> System.out.println("iResultCode = " + iResultCode);
>       
> byte[] yaResponse = post.getResponseBody();
>                       
> System.out.println("Server response:");
>                       
> BufferedWriter out = new BufferedWriter(new
> FileWriter("C:\\temp\\mytest.htm"));
> out.write(new String(yaResponse));
> out.close();
> 
> hc.endSession();
> ===================================================================
> 
> 


-- 
OSCOM - Open Source Content Management Conference
September 25th - 27th 2002, Berkeley, California
http://www.oscom.org/conferences/berkeley2002/


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to