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

D

Dobedani

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
 
A

Anton Spaans

Dobedani said:
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,999
Messages
2,570,243
Members
46,838
Latest member
KandiceChi

Latest Threads

Top