You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by Oleg Kalnichevski <ol...@apache.org> on 2003/08/02 19:55:12 UTC

Re: Does HTTPClient consults with browser when it is running underjava plugin.

> As I understood from your explanation, It is look like httpclient's initial
> httpstate can not set to with above  session / encrypted security cookies?
> Is that right...
> 

Reddy,
I am afraid my explanations so far have caused more confusion that
clarity. Of course, you can set any initial cookies you like. All that I
am trying to say is that you should be using HttpState APIs.


HttpClient httpclient = new HttpClient();
// Correct. This will work
httpclient.getState().addCookie(
  new Cookie("www.whatver.com", "jsession", "topsecret", 
  "/", -1, false));
GetMethod httpget = new GetMethod("http://www.whatever.com");
// Incorrect. This will not work
httpget.setRequestHeader("cookie", "jsession=topsecret");
httpclient.executeMethod(httpget);
System.out.println(httpget.getStatusLine().toString()); 

Use the trick suggested by Adrian to retrieve the session cookie and to
pass it as a parameter to the applet and you should be all right

Oleg