I am iterating over a Collection in a
JSP using JSTL in such a way that to display the code and description for each member of the collection, I write this:
I want to escape the
String referenced by "description" to make it JavaScript-safe by using the Apache Commons
StringEscapeUtils class. It has a method called escapeJavaScript that takes the String to be escaped and returns the escaped String. With a scriptlet, I could simply write something like this:
But I'm trying to avoid that...
By the way, we're using
Struts, but in this particular case, we retrieve the Collection of results from the Hibernate end and pass it all the way up to the Action class where it's placed in the request--the results aren't stored in a Struts form class, so it seems like the best place to escape the data would be here in the JSP.
[ November 16, 2005: Message edited by: Stephen Huey ]