Hi Folks,
I could set the domain explicitly and add the cookie to my response
Object but when I retrive the domain using getDomain() method of
Cookie object using getCookies() method with request object
I always get null value.
Could someone in this Servlets mailing list
help me why am I getting null value.
Here is the code snippet.
*****************************************************************
Cookie co = new Cookie("portalname", "odyssey.ibelong.net");
co.setDomain(".ibelong.net");
co.setPath("/");
co.setMaxAge(999);
response.addCookie(co);
******************************************************************
When I retrive that cookie in another new browser session with some other
servlet
without deleting the cookies in my hard disk, I get domain value of that
cookie
is " null " , but when I opened the cookie file it is clear with domain of
what I set.
like this
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
.ibelong.net TRUE / FALSE 994897100 portalname odyssey.ibelong.net
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Here is the code to retrive the cookies from request object.
----------------------------------------------------------------------------
Cookie[] cookies = request.getCookies();
for (int i = 0; cookies != null && i < cookies.length; i++) {
Cookie c = cookies[i];
if (c.getName().equals("portalname")) {
System.out.println("Domain =" + c.getDomain());
}
}
----------------------------------------------------------------------------
request and response are the HttpServletRequest and HttpServletResponse
objects.
Thanks in advance,
Naveen.
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html