How to properly escape triple nested quotes in JSP tags

ZZ Coder picture ZZ Coder · Aug 6, 2009 · Viewed 7.8k times · Source

We just upgraded Tomcat and the newer Tomcat doesn't like nested quotes in the tag, so we have to alternate between single and double quotes. For example,

We used to have,

<form id="search" action="<fmt:message key="search.url"/>">

Now we can change it to,

<form id="search" action="<fmt:message key='search.url'/>">

What should I do if the quotes are triply nested like this,

<form id="search" action="<fmt:message key='<c:out value="${requestScope.search_url}"/>'/>">

The above tag doesn't compile.

Answer

D. Wroblewski picture D. Wroblewski · Aug 7, 2009

If you don't want do update all your jsp:s just for the tomcat upgrade, set the system property "org.apache.jasper.compiler.Parser.STRICT_QUOTE_ESCAPING" to false.

Easiest way to this is by editing catalina.sh and adding the following to JAVA_OPTS:

-Dorg.apache.jasper.compiler.Parser.STRICT_QUOTE_ESCAPING=false