Aren’t tag attributes declared in the TLD?

image with no caption

With custom tags, including the JSTL, the tag attributes are defined in the TLD. Remember? This is the TLD from the custom <my:advice> tag from the last chapter:

<tag>
    <description>random advice</description>
    <name>advice</name>
    <tag-class>foo.AdvisorTagHandler</tag-class>
    <body-content>empty</body-content>

    <attribute>
        <name>user</name>
        <required>true</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
</tag>

So, these are the things the developer who is using a tag needs to know. What’s the attribute name? Is it optional or required? Can it be an expression, or must it be only a String literal?

But while you do specify custom tag attributes in a TLD, you do NOT specify tag file attributes in a TLD!

That means we still have a problem—how does the page developer know what attributes the tag accepts and/or requires? Turn the page...

Get Head First Servlets and JSP, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.