JSP: setting special characters for a cookie value

I've noticed that with Tomcat 5.5.12 (and other JSP engines?), if I save special characters in a cookie (with cookie.setValue()), it doesn't work. More specifically, when I load a page later on and attempt to retrieve one of those cookie values, I see nothing. Note that cookie values that do not contain space, comma, quote, or semicolon work fine. So what's the best way to save cookie values if they have special characters? Do I have to use JavaScript's escape and unescape functions? I'd prefer to keep my solution within JSP, but if using JavaScript is the preferred solution, then so be it.

This is my first experts exchange question, so I'm not sure how I'll get an answer. Please advise and send your answer to <mail removed by Venabili>
Thanks,
John
jdean4Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

bloodredsunCommented:
use java.net.UrlEncoder.encode( "a String" , "UTF-8") and then the corresponding decoder object java.net.UrlDencoder.decode( "a String" , "UTF-8")

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
bloodredsunCommented:
And by the way john, we try to keep the answers posted on EE so that it is searchable for future use. Also, I'll get one of the PE's to remove your email (unless of course you like lots of spam from spam crawlers)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JSP

From novice to tech pro — start learning today.