I'm totally stuck on this, I'm trying to escape a single quote in a JSP. I have some data that I'm outputting directly into a JS string and the single quotes seem to be causing issues.
Here is my code:
<dsp:droplet name="/atg/dynamo/droplet/ForEach">
<dsp:param value="${CommerceItems}" name="array" />
<dsp:param name="elementName" value="CommerceItem" />
<dsp:oparam name="outputStart">
var itemNameList ='
</dsp:oparam>
<dsp:oparam name="output">
<dsp:getvalueof id="Desc" param="CommerceItem.auxiliaryData.productRef.displayName">
${fn:replace(Desc, "'", "\\/'")}
</dsp:getvalueof>
</dsp:oparam>
<dsp:oparam name="outputEnd">';</dsp:oparam>
</dsp:droplet>
And here is the output that Im getting:
var itemNameList ='
Weyland Estate Santa Barbara Pinot Noir
Raymond \/'Prodigal\/' North Coast Cabernet Sauvignon
Chateau Haute Tuque';
But this is wrong, and I just need /'Prodigal'/
or no single quotes at all!
EDIT: Or I actually need to escape quotes with \
backward slash?