I set a cookie like this from a servlet (URI=
/app/servlet/myPackage.CookieTest):

                Cookie userCookie = new Cookie("someName", "someValue");
                userCookie.setMaxAge(60*60*24*365);
                response.addCookie(userCookie);

I later try to read the cookies using a JSP page like this (URI=
/app/getCookieValue.jsp):

                Cookie[] cookies = request.getCookies();
                Cookie cookie;
                for(int i=0; i<cookies.length; i++)
                {
                        cookie = cookies[i];
                        out.print(cookie.getName() + "=");
                        out.print(cookie.getValue() + "\n");
                }

I get nothing in the results, however, if I try to get and print the
cookie values from the same servlet, I get all cookies that were set and
the sessionid cookie as well. What is going on? How can I set cookies in
a servlet and get their values from a jsp file (btw, the jsp file is in
the same package).

PS Is this the right forum for this question?

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to