18.2. Tags with BodiesCustom tags can do more than just output data controlled by parameters. A custom tag can have a body, which it can control in arbitrary ways. Listing 18.2 shows such a custom tag that can be used to display its body, hide it, or even reverse it. The result is shown in Figure 18.1. Figure 18.1. The result of a custom tag.[View full size image] ![]() Listing 18.2. A custom tag with a bodyThis example loads the same tag library as used in Listing 18.1 and again specifies that it will be using the awl prefix to access the tags. The tag used this time is called awl:maybeShow, and it has a parameter called show that controls what the tag should do with its body. show may be set to "no," in which case the body is hidden from the page; "yes," in which case the body is displayed; or "reverse," in which case the body is shown backward.Note that the body of the awl:maybeShow tag may include anything, including other JSP tags. This will be true of any custom tag that has been properly programmed. This property is described by saying that JSP tags can be nested. From here on it will be assumed that the body of any tag can contain any other tag unless otherwise noted. |