HttpEntity entity = null;
ResponseHandler <String> responseHandler = null;
try {
BasicHttpContext localContext = new BasicHttpContext();
// Create a local instance of cookie store
CookieStore cookieStore = new BasicCookieStore();
localContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);
Header sessionHeader = null;
if(this.loginAsUrl != null ) {
String loginAsUri = this.host + this.loginAsUrl;
String loginAsParamString = "?" + this.loginAsUserParam + "&" + this.loginAsPasswordParam;
HttpGet req2 = new HttpGet ( loginAsUri + loginAsParamString );
System.out.println("loginAsUrl:" + loginAsUri + loginAsParamString);
req2.setHeader("Connection","Keep-Alive");
HttpResponse rsp = client.execute(req2, localContext);
Header[] headers = rsp.getAllHeaders();
for (int i=0; i<headers.length; i++) {
Header hdr = headers[i];
String headerValue = hdr.getValue();
if (headerValue.startsWith("JSESSIONID")) {
sessionHeader = hdr;
}
System.out.println("login: " + hdr.getName() + " : " + hdr.getValue());
}
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));
}
}