0

I have this code bit:

var description = '${requestScope.description}';

In the above code if

${requestScope.description} = '''''''''

IE is throwing script error. How to solve this problem?

bPratik
  • 6,894
  • 4
  • 36
  • 67
Chinna
  • 156
  • 1
  • 1
  • 11
  • You mean to same that description itself is a consecutive quotes? – sundar Aug 14 '12 at 09:25
  • 1
    possible duplicate of [How to escape apostrophe or quotes on a JSP ( used by javascript )](http://stackoverflow.com/questions/1470768/how-to-escape-apostrophe-or-quotes-on-a-jsp-used-by-javascript) – xdazz Aug 14 '12 at 09:25

1 Answers1

0

Can you fix it using the technique mentioned in https://stackoverflow.com/a/1473192/476786 as suggested by @xdazz.

If not, try using double quotes as follows:

var description = "${requestScope.description}";

Edit: OP says that description could also potentially contain " (double quotes):

In that case, you could replace the double quotes before you output the string as:

var description = "${requestScope.description.replace("\"", "''")}";

This would replace all instances of double quotes with 2 single quotes.


Please note that my jsp isvery weak, and as such the code sample above might need a tweak or two... :)

Community
  • 1
  • 1
bPratik
  • 6,894
  • 4
  • 36
  • 67
  • @xdazz it is working for Apostrophe but if "${requestScope.description}" value is "(double quotes) it is not working again the same script error – Chinna Aug 14 '12 at 09:50