hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joan Balagueró <joan.balagu...@grupoventus.com>
Subject RE: Question About Cookies
Date Wed, 05 Mar 2008 19:30:55 GMT
Hello,

Thanks for your response.

Now I know how to send a cookie just related to one thread. But how to
receive a cookie from my remote server?

I was using : Cookie[] auxCookies = objHttp.getState().getCookies();

Now I know this is incorrect. I suppose that I must get cookies from the
Post method. But how? Should I use the
"method.getResponseHeader("Set-Cookie")? Or there is another way?


Thanks,

Joan.

 

-----Mensaje original-----
De: Roland Weber [mailto:ossfwot@dubioso.net] 
Enviado el: miércoles, 05 de marzo de 2008 19:38
Para: HttpClient User Discussion
Asunto: Re: Question About Cookies

Hello Joan,

there is no need to shout.

> The question is: doing this, am I setting this cookie for all threads or
> just for the current thread that is executing this code?

For all threads.

> Obviously, I want
> to set this cookie just for the current thread, not for all. Is this
> correct? And if not, how should I do it?

You should have a separate HttpState object for each thread
instead of using the default HttpState object for all of them:
http://hc.apache.org/httpclient-3.x/apidocs/org/apache/commons/httpclient/Ht
tpClient.html#executeMethod(org.apache.commons.httpclient.HostConfiguration,
%20org.apache.commons.httpclient.HttpMethod,%20org.apache.commons.httpclient
.HttpState)

> And the following question is: this request is sent to another servlet,
that
> reads it. But if I examine the HttpServletRequest, I always get null for
> cookies attribute. It’s like httpclient is not including the cookie in the
> request I’m sending to the remote servlet.

Check the domain and path attributes of your cookie.
Enable wire logging to see wether the cookie is sent or not.
http://hc.apache.org/httpclient-3.x/logging.html

hope that helps,
   Roland


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Mime
View raw message