Search code examples
jspprototypejsjsp-tags

JSP parses PrototypeJS template tags


I'm using prototypejs templates on a JSP file. But jsp file tries to parse #{} tags of prototypejs templates and hence it breaks.

How can I have jsp not parse them. I other words, how can I escape those tags?

Thanks.


Solution

    1. Escape it with \: var template = new Template('<a href="\#{href}" title="\#{title}">\#{name}</a>');

    2. Encode it as entity: var template = new Template('<a href="&#35;{href}" title="&#35;{title}">&#35;{name}</a>');

    3. Move it to JavaScript file.

    4. Move it to Java code and write on JSP using EL ${} or JSTL <c:out /> or Stuts <bean:write />