public static ApiFactory getInstance(String url, String userName, String password) {
String sessionId = null;
client = new DefaultHttpClient();
ConstantUtil.setHostUrl(url);
ConstantUtil.setUserName(userName);
ConstantUtil.setPassword(password);
try {
request = new HttpGet(ConstantUtil.getLoginUrl());
response = client.execute(request);
final Header[] headers = response.getHeaders("Set-Cookie");
for (int i = 0; i < headers.length; i++) {
if (headers[i].toString().indexOf("JSESSIONID") > 0) {
int start = headers[i].toString().indexOf("JSESSIONID");
int end = headers[i].toString().indexOf(";");
sessionId = headers[i].toString().substring(start, end);
}
}
ConstantUtil.setLoginJsessionId(sessionId);
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
request.abort();
}
not able to get the authentication myloginUrl is... String loginurl = ConstantUtil.getHostUrl() + "/j_spring_security_check?j_user="+ getUserName() + "&j_passw=" + getPassword(); actually i need jsessionId which i need for the later purpose when i will post the json data.