William Krick
2016-06-28 18:05:47 UTC
I've run into an interesting situation with un-escaped double quotes in
JavaScript in a JSP.
I have some JavaScript code like this...
var companyName = "${actionBean.company.name}";
...which breaks if the company name contains double quotes.
The same situation can happen if the company name contains a single quote
and the javascript code quotes using single quotes...
var companyName = '${actionBean.company.name}';
The only workaround I've been able to come up with involves adding new
methods to the company object that I can call to get a JavaScript escaped
version of the string using Apache
commons StringEscapeUtils.escapeJavaScript().
JavaScript in a JSP.
I have some JavaScript code like this...
var companyName = "${actionBean.company.name}";
...which breaks if the company name contains double quotes.
The same situation can happen if the company name contains a single quote
and the javascript code quotes using single quotes...
var companyName = '${actionBean.company.name}';
The only workaround I've been able to come up with involves adding new
methods to the company object that I can call to get a JavaScript escaped
version of the string using Apache
commons StringEscapeUtils.escapeJavaScript().