Using CookieModule.HTTPClient class - TechRepublic
General discussion
June 26, 2003 at 02:38 PM
rashmigopinath

Using CookieModule.HTTPClient class

by rashmigopinath . Updated 23 years ago

Hi,
I have a servlet filter which receives client cookies from a request. I need to send these cookies to another servlet. For this I am using the HTTPClient.HTTPConnection object to get connected to the servlet URL.
I am adding the cookies using the CookieModule class as follows:

HTTPConnection con = new HTTPConnection(myUrl);
con.addDefaultModule(Class.forName
(“HTTPClient.CookieModule”), 1);
CookieModule.setCookiePolicyHandler(null);
System.getProperties().put
(“HTTPClient.cookies.save”,”true”);
//myCookie is a cookie object.
CookieModule.addCookie(myCookie);
//To send the actual request
HTTPResponse rsp1 = con.Get(myUrl);

In the servlet to which I am connecting, I am able to receive the parameters which I pass through the URL. But the cookie information is not getting passed.
In the receiving servlet, I do a request.getCookies(), which is returning null.

How do I pass the Cookie information to the next servlet?

Thanks,
Rashmi.

This discussion is locked

All Comments