Friday, February 09, 2007

JSP: custom tag to modify its body

This is a skeleton of what is needed to build a custom jsp tag which does something to its body. For example a tag could change the urls of all the links found in its body.



make a file called CustomTag.tld and put it into WEB-INF:


use it like this on your JSP:
<%@ taglib uri="com.mycompany.CustomTag" prefix="x"%>

<x:ct>
here is some stuff inside the tag!
<c:out value="${someparam}"/>
</x:ct>

1 comment:

  1. Nice work! Very informative and helpful for jsp beginners. :)

    ReplyDelete