JSP: setting special characters for a cookie value

Posted on 2006-03-22
Last Modified: 2008-02-01
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>
Question by:jdean4
    LVL 29

    Accepted Solution

    use "a String" , "UTF-8") and then the corresponding decoder object "a String" , "UTF-8")
    LVL 29

    Expert Comment

    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)

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Join & Write a Comment

    Suggested Solutions

    This post first appeared at Oracleinaction  ( Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
    This paper addresses the security of Sennheiser DECT Contact Center and Office (CC&O) headsets. It describes the DECT security chain comprised of “Pairing”, “Per Call Authentication” and “Encryption”, which are all part of the standard DECT protocol.
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now