With request.getCookies() I do not get all cookies!

Discussion in 'Java' started by Dobedani, Jun 27, 2005.

  1. Dobedani

    Dobedani Guest

    Dear All,

    I have written a Java Server Page and I have added this as my first
    line of Java code:
    Cookie cookies[] = request.getCookies();

    When I loop through the cookies like this
    out.println("<table>");
    for (int i=0; i<cookies.length; i++) {
    out.println("<tr>");
    out.println("<td>" + cookies.getName() + "</td>");
    out.println("<td>" + cookies.getDomain() + "</td>");
    out.println("<td>" + cookies.getPath() + "</td>");
    out.println("<td>" + cookies.getValue() + "</td>");
    out.println("<td>" + cookies.getMaxAge() + "</td>");
    out.println("</tr>");
    }
    out.println("</table>");
    I get all the cookies BUT ONE!

    I make sure I use the same browser window throughout. I am running all
    kinds of applications on my machine, e.g. some based on ASP Classic
    etc. I am also runnig a CGI application developed in Delphi with an
    add-on called CGI Expert. In that application a cookie is set with name
    $$Default. With ASP, Perl etc. my scripts show all the (session)
    cookies like JSESSIONID, ASPSESSIONXXX, incl. the one called $$Default.
    However, when I run my Java Server Page, I see all those other cookies
    but the $$Default cookie is not shown!!!

    Unfortunately, I am interested to get hold of that very cookie! Is
    there maybe a way to get hold of something that is send along in the
    headers called HTTP_COOKIE? I have already tried to use a servlet and
    to get this thing by invoking:
    servlet.getInitParameter("HTTP_COOKIE")
    to no avail. Please help! TIA

    Kind regards,
    Dobedani
    Wageningen
    The Netherlands
    Dobedani, Jun 27, 2005
    #1
    1. Advertising

  2. Dobedani

    Anton Spaans Guest

    "Dobedani" <> wrote in message
    news:...
    > Dear All,
    >
    > I have written a Java Server Page and I have added this as my first
    > line of Java code:
    > Cookie cookies[] = request.getCookies();
    >
    > When I loop through the cookies like this
    > out.println("<table>");
    > for (int i=0; i<cookies.length; i++) {
    > out.println("<tr>");
    > out.println("<td>" + cookies.getName() + "</td>");
    > out.println("<td>" + cookies.getDomain() + "</td>");
    > out.println("<td>" + cookies.getPath() + "</td>");
    > out.println("<td>" + cookies.getValue() + "</td>");
    > out.println("<td>" + cookies.getMaxAge() + "</td>");
    > out.println("</tr>");
    > }
    > out.println("</table>");
    > I get all the cookies BUT ONE!
    >
    > I make sure I use the same browser window throughout. I am running all
    > kinds of applications on my machine, e.g. some based on ASP Classic
    > etc. I am also runnig a CGI application developed in Delphi with an
    > add-on called CGI Expert. In that application a cookie is set with name
    > $$Default. With ASP, Perl etc. my scripts show all the (session)
    > cookies like JSESSIONID, ASPSESSIONXXX, incl. the one called $$Default.
    > However, when I run my Java Server Page, I see all those other cookies
    > but the $$Default cookie is not shown!!!
    >
    > Unfortunately, I am interested to get hold of that very cookie! Is
    > there maybe a way to get hold of something that is send along in the
    > headers called HTTP_COOKIE? I have already tried to use a servlet and
    > to get this thing by invoking:
    > servlet.getInitParameter("HTTP_COOKIE")
    > to no avail. Please help! TIA
    >
    > Kind regards,
    > Dobedani
    > Wageningen
    > The Netherlands
    >


    Very simple:
    The official api-documentation of javax.servlet.http.Cookie specifies this
    for the name of the cookie:
    ====================
    The name must conform to RFC 2109. That means it can contain only ASCII
    alphanumeric characters and cannot contain commas, semicolons, or white
    space or (!)begin with a $ character(!). The cookie's name cannot be changed
    after creation
    ====================

    That means that the name "$$Default" is not valid for a cookie....
    -- Anton.
    Anton Spaans, Jun 28, 2005
    #2
    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. Alex Nitulescu

    Response.Cookies vs Request.Cookies

    Alex Nitulescu, Feb 3, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    8,484
    Hans Kesting
    Feb 3, 2005
  2. guyhey
    Replies:
    2
    Views:
    5,993
    zvasanth
    Jan 12, 2008
  3. Kaspar Minosiants

    [Q] HttpServletRequest.getCookies()

    Kaspar Minosiants, Jul 8, 2003, in forum: Java
    Replies:
    2
    Views:
    2,310
    Kaspar Minosiants
    Jul 9, 2003
  4. mhshpk
    Replies:
    0
    Views:
    548
    mhshpk
    Jul 18, 2007
  5. _Who
    Replies:
    7
    Views:
    2,656
Loading...

Share This Page