The Java EE 5 Tutorial

Tags with Bodies

A simple tag can contain custom and core tags, HTML text, and tag-dependent body content between the start tag and the end tag.

In the following example, the Duke’s Bookstore application page tut-install/javaeetutorial5/examples/web/bookstore3/web/bookshowcart.jsp uses the JSTL c:if tag to print the body if the request contains a parameter named Clear:

<c:if test="${param.Clear}">
    <font color="#ff0000" size="+2"><strong>
     You just cleared your shopping cart!

jsp:body Element

You can also explicitly specify the body of a simple tag by using the jsp:body element. If one or more attributes are specified with the jsp:attribute element, then jsp:body is the only way to specify the body of the tag. If one or more jsp:attribute elements appear in the body of a tag invocation but you don’t include a jsp:body element, the tag has an empty body.