Web tier: servlets, JSP, Web frameworks: Handling Special Characters in JSP
Hi Iam getting Item Name from Data Base that contains Sp Chars like ',"/- etc. When Iam displaying the same it is throwing java script error(; expected). Also when sending the same via URL to new window also it is throwing exceptions. How to handle this? Regards B S Reddy
- Posted by: Srin Reddy
- Posted on: February 07 2007 12:19 EST
you don't. decode them to UTF-8 before displaying them... make sure your database is set to UTF-8 encoding as well, if your using one.
You could also see if Commons Lang's StringEscapeUtils could help you out. It has methods for HTML, XML and Java and corrects issues with special characters in strings. http://jakarta.apache.org/commons/lang/api/org/apache/commons/lang/StringEscapeUtils.html Hope this helps. Ben http://www.benwilcock.net