One more thing I will like to share, the way I am trying to capture cokkies
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpContext localContext = new BasicHttpContext();
try{
HttpClient client = new HttpClient();
// Setting Login URL in a POST method
String loginURL = "http://localhost:8070/jasperserver/rest/login";
HttpPost loginCall = new HttpPost("http://localhost:8070/jasperserver/rest/login");
PostMethod postMethod = new PostMethod(loginURL);
httpClient.getCredentialsProvider().setCredentials(
new AuthScope("http://localhost", 8070),
new UsernamePasswordCredentials("username", "password"));
cookieStore = new BasicCookieStore();
// Set authentication parameters
postMethod.addParameter("j_username", "username");
postMethod.addParameter("j_password", "password");
int statusCode = client.executeMethod(postMethod);
if (statusCode != HttpStatus.SC_OK) {
System.out.println("Login failed: " + postMethod.getStatusLine());
return;
}else
System.out.println("The value of login status is:"+postMethod.getStatusLine());
// Create local HTTP context
// Bind custom cookie store to the local context
localContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);
loginCall.setHeader("content-type", "application/x-www-form-urlencoded");