I am sending org.apache.commons.httpclient.methods.PostMethod
through org.apache.commons.httpclient.HttpClient
class. This has a member of type HttpState
and that contains cookies.
I am explicitly setting cookies in this state member instance as following:
HttpState state = httpClient.state;
state.clearCookies();
state.addCookies(cookiesArray);
httpStatusCode = httpClient.executeMethod(httpPost);
Now I get this request in the form of HttpServletRequest
. But in this request I don't get any cookies that was set by me explicitly as shown in above code.
Any pointer would be of great help to me.
I have tried the same stuff with org.apache.commons.httpclient.methods.GetMethod
too but no success.
Thanks very much in advance...
-Ketan
I myself will give the answer now, though - obviously - I had found the answer in 2-3 days after asking the question.
If I pass the cookie name="JSESSIONID" with path="/", and then I pass another cookie with name="JSESSIONID" with path="/mail/corporate" then second cookie is not sent. The reason is because the cookie is already set at the root path and hence with the same name but different path cookie is not going to set. That was the reason.
Solution I Applied: One of 2 JSESSIONID cookies was not useful to me. Hence I just replace the value of the required cookie with the one supplied at the path="/". That solved the issue.