| ||||||||||||||||||||||
Find this tutorial in: /usr/local/resin/webapps/resin-doc/jsp/tutorial/tagfile-basic
Try the Tutorial JSP 2.0 introduces XML-based tag files. Instead of having to write Java code for custom tags, applications can use XML or JSP syntax for their tags. Tag files do not require .tld files, making development simpler.
Tag files in JSP 2.0 look and run like normal JSP files with some extra directives. This example definine a tag attribute "a" which takes a String value. It prints a simple message.
The extension identifies the tag as a JSP tag file using XML syntax. The example could also have used for a tag file in JSP syntax. Tag files normally belong in WEB-INF/tags, although the location is configurable.The tag example uses the JSP 2.0 Expression Language as an example and as a way to avoid any Java in the tag file. The ${a} tells the tag to look in the pageContext for a local variable a. The value of a is assigned by the tag attribute as defined in the attribute directive.
Using tag files is similar to using normal JSP tags. This example uses the XML syntax, although normal JSP syntax would work, too. The namespace prefix tells JSP where to look for the tag. In this case it will look in WEB-INF/tags.
|