I'm working with JSWDK 1.0.1 and have to simple JSP pages for testing cookie
reading and writing (copied below). I turn on warnings about cookies in IE
and can inspect the contents of the cookie coming down to my browser.
However, when I look for cookies coming back to the server there are none.
I'm suspicious that the problem is related to running on
http://localhost:8080/ <http://localhost:8080/> rather than a "real"
domain. Anyone seen similar behavior? Recommendations???
-Matthew
PutCookie.jsp:
<%
Cookie ts = new Cookie("CookieTime",(new java.util.Date()).toString());
response.addCookie(ts);
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF">
Sending Cookies
</body>
</html>
GetCookies.jsp:
<%
System.out.println("Received page request");
Cookie cookies[] = request.getCookies();
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF">
<%
if ((cookies == null) || (cookies.length == 0))
{
%>
<p>Found <%=cookies.length%> cookies</p>
<table width="100%" border="1">
<tr>
<td>Name</td>
<td>Value</td>
<td>Comment</td>
<td>Max Age</td>
</tr>
<%
for (int i=0; i < cookies.length; i++)
{
Cookie c = cookies[i];
System.out.println("Name: " + c.getName() + " Value: " + c.getValue() + "
MaxAge: " + c.getMaxAge());
%>
<tr>
<td><%=c.getName()%></td>
<td><%=c.getValue()%></td>
<td><%=c.getComment()%></td>
<td><%=c.getMaxAge()%></td>
</tr>
<%
}
%>
</table>
<p> </p>
<p> </p>
<%
}
else
{
System.out.println("NO COOKIES FOUND");
%>No Cookies Found<%
}
%>
</body>
</html>
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets