tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul Wallace" <paul.wall...@mustang-technologies.com>
Subject cookie retrieval
Date Fri, 08 Mar 2002 03:51:31 GMT
Hi, a have a JSP page to setup a cookie (Tomcat server):

cook = new Cookie("memberCookie", userid);
cook.setPath("c:/Program Files/jakarta-tomcat-4.0/webapps/mydir/login/");
response.addCookie(cook);
response.sendRedirect("http://myhost/somelocation/mydir/bookings/enterDate.j
sp");

and the page to retrieve the cookie (enterDate.jsp) is:

Cookie cookies[] = request.getCookies();
if(cookies != null) {
    for(int i = 0; i < cookies.length; i++) {
        if (cookies[i].getName().equals("memberCookie"));
        out.println("Welcome: " + cookies[i].getValue());
        }
 }

Here's the conundrum, if the cookie is retrieved from a page that is in a
DIFFERENT directory that setup the cookie , the output (getValue) returns
only a sessionID ie "8455352001D0C01849A2C480576723D8" and not the required
value. BUT, if the cookie is retrieved from a file in the SAME directory of
setup, the desired output is obtained, plus the same JSESSIONID info. How
may I simply obtain the value of the cookie from any directory, and not the
session ID? I have tried using setPath (above) pointing to the setup and
destination directories with same unwanted session ID output.
     Perhaps my syntax of setPath is the problem here? Surely I do not have
to setup and retrieve cookies using files that are in the same directory?

Thanks for all input

Paul.



--
To unsubscribe, e-mail:   <mailto:tomcat-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-dev-help@jakarta.apache.org>


Mime
View raw message