What can be in a tag body

A tag can have a body only if the <body-content> element for this tag is not configured with a value of empty. The <body-content> element can be one of either three or four values, depending on the type of tag.

<body-content>empty</body-content>

Note

The tag must NOT have a body.

<body-content>scriptless</body-content>

Note

The tag must NOT have scripting elements (scriptlets, scripting expressions, and declarations), but it CAN have template text and EL and custom and standard actions.

<body-content>tagdependent</body-content>

Note

The tag body is treated as plain text, so the EL is NOT evaluated and tags/actions are not triggered.

<body-content>JSP</body-content>

Note

The tag body can have anything that can go inside a JSP.

THREE ways to invoke a tag that can’t have a body

Each of these are acceptable ways to invoke a tag configured in the TLD with <body-content>empty</body-content>.

  1. An empty tag

    image with no caption
  2. A tag with nothing between the opening and closing tags

    image with no caption
  3. A tag with only <jsp:attribute> tags between the opening and closing tags

    <mine:advice>
       <jsp:attribute name="user">${userName}</jsp:attribute>
    </mine:advice>

    Note

    The <jsp:attribute> tag is the ONLY thing you can put between the opening and closing tags of a tag with a <body-content> of empty! It’s just an alternate way to put ...

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.