When trying to set a cookie in Tomcat 3.2.4 I see the error below and the cookie is not set. This is happening both in a JSP or servlet.
ERROR BEGINS '$' not allowed as first char of Cookie name Cookie Header: $Version=1; ERROR ENDS
Of course this error message is written on the live console. I'm bewildered because I'm not sure why Tomcat is adding the dollar sign. Have you ever come across such a problem? I gather it's to do with version 0 and 1 of the cookies. Explorer 6 seems to be happy but Firefox and Opera won't have it. I'm also making sure that I add the cookie to the response before commiting the response.
Please don't ask why I'm not using the latest version of Tomcat, I'm at work trying to fix an old app. No one has ever bothered to upgrade it
Thank you, Ernest [ August 05, 2005: Message edited by: ernest fakudze ]
In a time of drastic change it is the learners who inherit the future. The learned usually find themselves equipped to live in a world that no longer exists.<br />Eric Hoffer
I'm confused - how can IE be happy if Tomcat has an error while trying to set the cookie? Doesn't mean that the cookie doesn't exist in the response that the browser gets back from the server?
Which J2EE version is Tomcat using, and if the cookie's name is "Version" as the error message implies, are you creating it using literal (new Cookie("Version", "1") ), or with a variable that you get from somewhere else for the cookie name?
Joined: Aug 27, 2001
Thanks for helping out. What I meant about IE being happy is that the error message was not appearing on the live console when the page was accessed through IE, but then IE can do wierd stuff sometimes.
All I was trying to do is set cookies on a login form and the Version thing just came out of the blue. Please see a sample of my code below:
I have just tested this thing on tomcat 4 again and there are no problems whatsoever. It seems that Tomcat 3 has got some serious issues when it comes to cookies.
Tomcat 3!! Isn't it older than me? ofcourse not. But its almost obselete.
Why Tomcat 3??
Joined: Aug 27, 2001
Yes, Tomcat 3 is almost obsolete but I'm operating in an environment where we don't really do java stuff. We mainly do ColdFusion, ASP and .net. This old app was written way back in those days and the sysadmin guys have not bothered to upgrade it You know hwat it's like.
As the app works fine in Tomcat 5, i will persuade them to upgrade.
Regards, Ernest [ August 08, 2005: Message edited by: ernest fakudze ]