K
Kai Grossjohann
I have a JSP which does request.addCookie(cookie), then <c:redirect/>
to a second JSP. Said second JSP reads the given cookies via JSP and
sees that all is well: the cookies have arrived. Said second JSP
*also* has some JavaScript code reading the same cookies, but they are
not found.
How come that JavaScript can't read the cookies set via JSP?
I create the cookies in the first JSP like this:
Cookie cook = new Cookie("foo", "bar");
cook.setPath("/evITA-Web");
response.addCookie(cook);
And the JavaScript code to read them looks like this:
function get_cookie(name) {
var regexp = new RegExp(name + "=([^;]+)");
var cookie_match = document.cookie.match(regexp);
if (cookie_match) {
return cookie_match[1];
} else {
return null;
}
}
I'm trying this out in IE 6 on W2k/pro. The server side is a Tomcat
5.0.16.
Kai
to a second JSP. Said second JSP reads the given cookies via JSP and
sees that all is well: the cookies have arrived. Said second JSP
*also* has some JavaScript code reading the same cookies, but they are
not found.
How come that JavaScript can't read the cookies set via JSP?
I create the cookies in the first JSP like this:
Cookie cook = new Cookie("foo", "bar");
cook.setPath("/evITA-Web");
response.addCookie(cook);
And the JavaScript code to read them looks like this:
function get_cookie(name) {
var regexp = new RegExp(name + "=([^;]+)");
var cookie_match = document.cookie.match(regexp);
if (cookie_match) {
return cookie_match[1];
} else {
return null;
}
}
I'm trying this out in IE 6 on W2k/pro. The server side is a Tomcat
5.0.16.
Kai