• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Tomcat refusing to set a cookie...

 
Ranch Hand
Posts: 216
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys,

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 ]
 
Ranch Hand
Posts: 429
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ernest,

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?

-Yuriy
 
ernest fakudze
Ranch Hand
Posts: 216
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Yuriy,

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.

Regards,
Ernest
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tomcat 3!! Isn't it older than me? ofcourse not. But its almost obselete.

Why Tomcat 3??
 
ernest fakudze
Ranch Hand
Posts: 216
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Adeel,

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 ]
 
And then the entire population worshiped me like unto a god. Well, me and this tiny ad:
New web page for Paul's Rocket Mass Heaters movies
https://coderanch.com/t/785239/web-page-Paul-Rocket-Mass
reply
    Bookmark Topic Watch Topic
  • New Topic