Gotcha! Tomcat strict quote escaping

So I was recently upgrading an older application from Tomcat 6.0.16 to 6.0.20 and started to see a JasperException appear on several JSP pages I was testing. The exception stated something similar to the following:

[insert your var here] is quoted with " which must be escaped when used within the value..

So I looked at my code and saw the exception was complaining about a line of code similar to the following which worked for years with no problems:

<jsp:include page="<%= "/dir/" +someVariable + "/page.jsp" %>" />

Huh? I had hundreds of JSP pages with syntax similar to the above which had been working for years. I thought to myself what a nightmare this would be to go find and fix all of these! However, after some searching around online I discovered this bug issue which talks about how Tomcat was not totally JSP 2.0 compliant and was handling such variable declarations incorrectly. Anyways, they “fixed” this major issue (following my sarcasm here?), in Tomcat 6.0.17 and luckily they anticipated what a huge issue this might cause for folks out here, so they introduced a catalina.propeties property that you can specify in your TOMCAT_HOME/conf/catalina.properties.

Just add the following config to your catalina.properties file and restart Tomcat:

# TURN OF STRICT PARSING EXCEPTIONS
org.apache.jasper.compiler.Parser.STRICT_QUOTE_ESCAPING=false

Hope that helps! Keep in mind that your code, if you don’t eventually “fix” it, may not work on other app servers.

Advertisements

4 comments

  1. Vibin

    Hi,

    Eventhough I added the above script in catalina properties.Iam getting the same error for my application..Please help me regarding

    Thanks,
    Vibin

  2. Zbigniew

    I also have the same problem 😦
    I have just changed the catalina.properties according to yours advices but it still does not work

  3. Leonor

    Because of high fevers with these infections and a complication of tmj massage treatment is
    a highly contagious but can be anywhere on one side of your body.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s