Search code examples
jspif-statementescapingexpressionquotes

JSP error escape quotes in expression


I need to check type to display correct message like:

${row.type} <c:if test="${row.stype ==\"Note\" }">Important Note</c:if>

But the problem that escaping produce strange error: Unable to analyze EL expression due to lexical analysis error

How it can be fixed? Thanks.


Solution

  • Double quotes must not be escaped in EL. Use single quotes if the tag attribute is in double quotes, and vice-versa:

    <c:if test="${row.stype == 'Note'}">Important Note</c:if>
    

    or

    <c:if test='${row.stype == "Note"}'>Important Note</c:if>