0

I have a web application game where i have some text stored in a database. Java/JDBC is used to get the text from a database and store it in an Arraylist. The Arraylist is sent to the client where a JSTL forEach loop is used to convert the Arraylist into a Javascript array of strings using <c:out value="eachString">

During the game, i use a HTML canvas, and i print the value of these strings onto the canvas using context.fillText().

However, because <c:out> automatically escapes things, when the text is printed out - the following sort of sentence is printed:

They couldn&#039;t do it

instead of:

they couldn't do it.

So i was wondering is there some kind of function or easy method i could use which would take the text passed to the fillText method and translate all the entity references into their actual values.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
rurounisuikoden
  • 269
  • 1
  • 4
  • 16
  • Does it represent user-controlled data? If not, then just don't use ``. – BalusC Jul 26 '15 at 18:28
  • The problem is if i don't use , the javascript array wont be created properly because semicolons, apostrophes etc won't be escaped out – rurounisuikoden Jul 26 '15 at 18:34
  • The `` is there not for. It's for escaping XML special characters, not for JS special characters. See also http://stackoverflow.com/a/9709168 how to properly escape JS in EL. – BalusC Jul 26 '15 at 20:42

0 Answers0