Search code examples
javajspjsp-tags

Is there any good reason to use <rtexprvalue>false</rtexprvalue> in JSP tags?


Is there any good reason to disallow scriptlet or EL expression to be inserted as attribute value?

Let's say we have tag:

<tag>
    <name>mytag</name>
    <tag-class>org.apache.beehive.netui.tags.tree.Tree</tag-class>
    <attribute>
        <name>attr</name>
        <required>false</required>
        <rtexprvalue>false</rtexprvalue>
        <type>boolean</type>
    </attribute>
</tag>

What could be a good reason for dissallowing the below?

<my:mytag attr="${setting}" />

Solution

  • I'd say it is mostly a backwards-compatibility measure, just like the ability to turn off EL completely for a given JSP.

    Maybe the tag library existed before EL, and uses the special syntax ${} for its own purposes. Maybe the attribute value frequently takes values that include a literal ${}.

    Without such a setting, existing code (in the tag library or the JSP) would need to be modified in order to still work after upgrading to the latest version of the Servlet spec.