Alden Penn wrote:
>
> ALL -
>
> I have been trying to get a servlet to set multiple
> cookies for some time now without success.  I've been
> using both the cookie object itself and the
> httpresponse method setHeader("Set-Cookie", String)
> and it seems like it only actually sets the last
> cookie on the browser.
>
> Or, am I doing something wrong ;)
>

 When you say "using the cookie object itself", do you mean
you've tried HttpResponse.addCookie?

 addCookie

      Adds the specified cookie to the response. It can be
      called multiple times to set more than one cookie.

 The behavior you describe for setHeader is correct, it
erases the old value. The 2.2 spec has a new HttpResponse
method:

 addHeader

      The setHeader method sets a header with a given name and
      value. If a previous header exists, it is replaced by the
      new header. In the case where a set of header values exist
      for the given name, all values are cleared and replaced
      with the new value. The addHeader method adds a header value
      to the set of headers with a given name. If there are no
      headers already associated with the given name, this method
      will create a new set.

 You might also want to check the archives (link at the bottom of
the message) for a thread with the subject "How to add multiple
cookies in 2.1". Actually, I'm being bad (bad programmer, no
programmer treat) for answering, since you probably should have
checked the archives  and the spec before posting. But since the
archive search function has been broken lately...


-cks

___________________________________________________________________________
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

Reply via email to