O'Reilly logo

Head First Servlets and JSP, 2nd Edition by Bert Bates, Bryan Basham, Kathy Sierra

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required