In working with this problem I am seeing a difference in what the
BasicCookieStore stores and what is in the headers. Here is my code:
BasicHttpContext localContext = new BasicHttpContext();
// Create a local instance of cookie store
CookieStore cookieStore = new BasicCookieStore();
localContext.setAttribute(ClientContext.COOKIE_STORE,
cookieStore);
//this.login(client, localContext);
String paramString2 = "USERNAME=" + this.parent.getUserName()
+ "&PASSWORD=" + this.parent.getPassword();
String thisUri2 = this.host + "/eng/control/login?" +
paramString2;
HttpGet req2 = new HttpGet ( thisUri2 );
req2.setHeader("Connection","Keep-Alive");
HttpResponse rsp = client.execute(req2, localContext);
Header[] headers = rsp.getAllHeaders();
for (int i=0; i<headers.length; i++) {
System.out.println(headers[i]);
}
The above code prints out:
Server: Apache-Coyote/1.1
Set-Cookie: JSESSIONID=073AF3D9B37540588F86BAF974B4BFB6.jvm1; Path=/eng
Set-Cookie: OFBiz.Visitor=10224; Expires=Sat, 21-Nov-2009 07:54:27 GMT;
Path=/
Set-Cookie: eng.autoUserLoginId=admin; Domain=""; Expires=Sat, 21-Nov-2009
07:54:27 GMT; Path=/
Content-Type: text/html;charset=UTF-8
Transfer-Encoding: chunked
Date: Fri, 21 Nov 2008 07:54:27 GMT
List<Cookie> cookies = cookieStore.getCookies();
System.out.println("cookies.size(): " + cookies.size());
for (int i = 0; i < cookies.size(); i++) {
System.out.println("Local cookie(0): " + cookies.get(i));
}
The above code prints:
cookies.size(): 1
Local cookie(0): [version: 0][name: OFBiz.Visitor][value: 10224][domain:
localhost][path: /][expiry: Sat Nov 21 00:54:27 MST 2009]
How can I have 3 'Set-Cookie' headers but cookieStore only shows 1?
Thanks,
-Al