Writing multiple cookies, only one is stored

Discussion in 'Java' started by Tim Strawhacker, Jul 18, 2003.

  1. Hello --

    I've got some code that adds five cookies to an HttpServletResponse by
    calling addCookie() on it. I know that the cookies are correct, and that
    I'm executing the code to add them. These cookies are sequentially added to
    the same HttpServletResponse object in the same doPost() method.

    When I call readCookies() on a later HttpServletRequest, I only get one
    cookie back -- the last one that was written. I thought at first that maybe
    I could write only one cookie per HttpServletResponse, so I was perhaps
    overwriting a "slot" in the HttpServletResponse structure, but I know I've
    seen examples that wrote multiple cookies together.

    Any idea what else could be going wrong?

    Thanks,
    Tim
     
    Tim Strawhacker, Jul 18, 2003
    #1
    1. Advertising

  2. Tim Strawhacker

    Sudsy Guest

    Tim Strawhacker wrote:
    > Hello --
    >
    > I've got some code that adds five cookies to an HttpServletResponse by
    > calling addCookie() on it. I know that the cookies are correct, and that
    > I'm executing the code to add them. These cookies are sequentially added to
    > the same HttpServletResponse object in the same doPost() method.
    >
    > When I call readCookies() on a later HttpServletRequest, I only get one
    > cookie back -- the last one that was written. I thought at first that maybe
    > I could write only one cookie per HttpServletResponse, so I was perhaps
    > overwriting a "slot" in the HttpServletResponse structure, but I know I've
    > seen examples that wrote multiple cookies together.
    >
    > Any idea what else could be going wrong?
    >
    > Thanks,
    > Tim
    >
    >


    And naturally you're using a different name for each cookie, right?
     
    Sudsy, Jul 19, 2003
    #2
    1. Advertising

  3. Tim Strawhacker

    Sudsy Guest

    Tim Strawhacker wrote:
    > "Sudsy" <> wrote in message
    > news:...
    >
    >>And naturally you're using a different name for each cookie, right?
    >>

    >
    >
    > Yup. I'm doing the addCookie() call in a loop. Here's my code:

    <snip>
    > Thanks for looking at it -- Tim
    >
    >


    Your code looks fine, almost identical to what I was using for some
    testing. Only snag is that my implementation works exactly as
    expected. There must be something else awry in your setup. Is there
    any unusual handling of pages, e.g. forwarding vs redirecting?
    What is the server environment?
     
    Sudsy, Jul 21, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. D. Shane Fowlkes
    Replies:
    3
    Views:
    631
    S. Justin Gengo
    Feb 24, 2004
  2. Alex Nitulescu

    Response.Cookies vs Request.Cookies

    Alex Nitulescu, Feb 3, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    8,495
    Hans Kesting
    Feb 3, 2005
  3. loveNUNO
    Replies:
    2
    Views:
    922
    loveNUNO
    Nov 20, 2003
  4. _Who
    Replies:
    7
    Views:
    2,679
  5. Author #1
    Replies:
    2
    Views:
    1,189
    Cowboy \(Gregory A. Beamer\)
    Apr 25, 2009
Loading...

Share This Page