I am John Regan.
Environment:
NT
IE 5.0
Tomcat 4.0
Struts 1.0
When a user requests our index page we write a pagehit sequence # to the
client's cookie through the following code:
//no cookie exits
else {
Cookie pcookie = new Cookie("P",r.getPagehitcode());
pcookie.setMaxAge(60*60*24*365);//1 year
response.addCookie(pcookie);
}
which works fine, I look in my cookies directory and find a file named
jbr@jsp[1].txt(where does it grab this name from?) which contains the
correct value for "P".
The user clicks on a link on the homepage, this where things start to go
very wrong. In the action class I loop through cookie values in the
following manner:
Cookie[] cookies = request.getCookies();
Cookie cookie;
Cookie schangecookie = null;
if (cookies != null) {
for(int i=0; i<cookies.length; i++) {
cookie = cookies[i];
servlet.log("cookie" + cookie.getName() + " " +
cookie.getValue());
if (cookie.getName().equals("P")) {
schangecookie = (Cookie)cookie.clone();
schangecookie.setValue(r.getPagehitcode());
response.addCookie(schangecookie);
}
}
The log shows the only cookie in the request is the following:
JSESSIONID A37259C0F90335C6B3B177A1C2679413
The "P" value which I see in my cookie is not in the request! Not to
mention, I don't where JSESSIONID is stored!
Can someone clue me in to what might be happening?
Any help is much appreciated!