Nicholas Barrington wrote:
>
> You need to set the cookie expiration time. This is not a JSP issue but to
> do with all cookies. If you want cookies to last a certain time you need to
> tell the client machine to store them that long.
I have to apologize for not being clear enough in my initial email.
I have set cookie.setMaxAge() to Integer.MAX_INT - no fool am I.
(Perhaps MAX_INT is too big?)
It still, however, doesn't persist past the lifetime of a single browser
session.
I also realize that it's not a JSP-specific issue, but I'm trying to set the
cookie from within a JSP page, so I asked here first. From a rough search, I
didn't find anything useful in the archives of either the servlet-interest or
jsp-interest mailing list. (at http://archives.java.sun.com) Cookies should be
pretty simple, so I was wondering if there's anything undocumented that you
have to do, like set the path or domain explicitly.
Perhaps someone could post a code fragment they have that successfully gets a
cookie to be added to the cookie file so I can compare with my own code, which
looks like this...
cookie = new Cookie("name",request.getParameter("name"));
cookie.setMaxAge(Integer.MAX_VALUE);
cookie.setPath("/");
response.addCookie(cookie);
If I add the cookie to the response, do I have to do so before writing
anything to "out"? I may be having a problem with HTML code in the generates
servlet being written out before I create my cookies. Investigation
continues...
--
Ethan Henry [EMAIL PROTECTED]
Java Evangelist, KL Group http://www.klg.com
"Software Development Productivity"
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JSP-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".