You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Jovie Castaneda <jo...@pure-commerce.com> on 2001/10/05 05:52:17 UTC
Cookies not working in Tomcat why?
Hope to have some inputs from you. I'm having trouble implementing cookies
in Tomcat
I wrote the following codes
Cookie cookie1 = new Cookie("User_ID", Integer.toString(userid));
Cookie cookie2 = new Cookie("MerchantID", Integer.toString(merchantID));
Cookie cookie3 = new Cookie("SecurityLevel",
Integer.toString(SecurityLevel));
res.addCookie(cookie1);res.addCookie(cookie2);
res.addCookie(cookie3);
res.sendRedirect("/test/servlet/MyServlet");
I am expecting to get the cookies I have set when I retrieve them from
"MyServlet"
I check them using this code:
if (cookies !=null){
for(int i=0; i< cookies.length; i++){
System.out.println("Name : "+cookies<i>.getName());
System.out.println("Value : "+cookies<i>.getValue());
}
}
My expected result should be the following:
Name: UserID
Value: UserID Value
Name: MerchantID
Value: MerchantID value
Name: SecurityLevel
Value: SecurityLevel value
But why am i getting only 1 value which happens to be
JSESSIONID ( coming from the session created)
and its sessionid as the value
why cant it create cookies and store the values in it?
Comments and Suggestions are highly appreciated :)