hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joan Balagueró <joan.balagu...@grupoventus.com>
Date Wed, 05 Mar 2008 18:22:32 GMT


I’ve a little question about cookies.


I’ve a MultiThreadedHttpConnectionManager, and I get an HttpClient instance
from it. This httpclient object IS SHARED by all threads of my servlet (it
means, I only have 1 instance of httpclient). I set the RFC-2109 in this


HttpClient objHttp = new HttpClient(new




Now I want to set cookies to this httpclient using httpstate. The following
piece of code is executed by every thread (every request) of my servlet:


HttpState initialState = new HttpState();

org.apache.commons.httpclient.Cookie(value_for_this_request, ……..));




The question is: doing this, am I setting this cookie for all threads or
just for the current thread that is executing this code? 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? Maybe set the cookies at method
level using method.setRequestHeader and setting the “Cookie” header and its
value as string?


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. But why? Is it not enough
specifying the cookie policity at httclient params level?



Thanks a lot,





  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message