Body content types of jsp custom tag tutorial

In any JSP custom tag you can put the any type of body like scriptlets, expression or text, but if you want to restrict the use to put body content to some specific type, you can mentioned same inside the LTD file while registering the tag. There is optional element where you can specify the body content type.

<tag>
    <name>iteration</name>
    <tagclass>com.java.connect.tag.IterationTagHandller</tagclass>
    <bodycontent>jsp</bodycontent>
    <attribute>
        <name>index</name>
        <required>true</required>
    </attribute>
</tag>

The valid types of body for custom tag are:

empty: If you keep body inside custom tag then compiler will give error.

tagdependent: You can keep any html/text inside body of custom tag, but scriptlets and expression will not be allowed.

scriptlets: You can keep any html/text, scriptlets and expression, every type of portion will be executed.

jsp: This is default type, if you don’t put any type of body content, or you can specify jsp as body content explicitly.