Search code examples
struts2migrationescapingstrutsfreemarker

org.apache.jasper.JasperException: An exception occurred processing [/jsp/include/actionError.jsp] when updated to struts 6.3.0.2


org.apache.jasper.JasperException: An exception occurred processing [/jsp/include/actionError.jsp] at line [61]

58:     </c:when>
59:     <c:otherwise>
60:         <t:actionmessage cssClass="text-error" templateDir="com/fs/util/strutsTemplates" template="actionmessage.ftl" theme="xxx" />
61:     </c:otherwise>
62: </c:choose>

I am trying to upgrade to struts 6.3.0.2 from 2.5.33 and this error occurs when am trying to run my application. Could you please let me know what could be the reason for the error at line no 61.

What changes can be made to the line 61?

Additional Info :

Caused by: Syntax error in template "strutsTemplates/actionmessage.ftl" in line 3, column 46:
Using ?html (legacy escaping) is not allowed when auto-escaping is on with a markup output format (HTML), to avoid double-escaping mistakes.
File: FMParser.java

class="${parameters.cssClass?html}"<#rt/>

Solution

  • After upgrading to Struts 6.x the Freemarker is also upgraded. The new Freemarker version is using auto-escape is on by default. But your old templates still using ?html to display output.

    The migration guide suggests you to stop using ?html:

    After migrating to the latest Freemarker (which enables auto-escaping by default) you should stop using ?html in your custom tags and freemarker based pages.