views:

167

answers:

0

I have cookies =

session_ser = "MTQzMzI5LSotMTI2NTg3MDM4OS0qLTkuNDguMTEyLjUxLSotSmF2YS8xLjYuMF8xMC1yYw%3D%3D-%2A-eb5fdd26da5e7e0a7c5a096b412dcae3"

With this cookies i want to access protected page from particular site

its working with HttpURLConnection ,but is not working with HttpClient

-------------code snipet for HttpURLConnection -----------------

HttpURLConnection conn = HttpURLConnection)url.openConnection()
conn.setInstanceFollowRedirects(false);
conn.setRequestProperty ("Cookie", cookiesName+"="+cookiesValue);
conn.connect();

I am getting protected page with above code

-------------code snipet for HttpClient-----------------

HttpClient client = new HttpClient();

GetMethod getMethod = new GetMethod(url);
getMethod.setFollowRedirects(false);
HttpClient client = new HttpClient();
Cookie c = new Cookie(DomnainName,cookiesName,cookiesValue,path,date,false);
client.getState().addCookie(c);
int a=client.executeMethod(getMethod);

But its giving me login page.expected out put is protected page

why this is not working with HTTPclient.

Http client version is 3.1,