I am retrieving a value from our DB using JSTL. I am inserting it right into some javascript to use it as a variable. I need the output of the value the JSTL is holding to be escaped because if there are single or double quotes it breaks my script. The value is user specified.
Example:
Doing the following:
<c:set var="myVar" value="Dale's Truck"/>
<script type="text/javascript">
var mayVar = '${myVar}';
</script>
Would actually end up looking like:
<script type="text/javascript">
var mayVar = 'Dale's Truck';//extra single quote breaks the JS
</script>
So I need to convert the JSTL var to be escaped like "Dale%27s Truck" before is gets to the JS because its already too late when it gets to my JS to be able to do it in JS.