Monday, May 5, 2008

JSP Custom Tags

http://java.sun.com/products/jsp/tutorial/TagLibrariesTOC.html

Working of custom tags: 3 steps are involved in working of JSP custom tags.
1. Defining the tag handler: This is the java class which actually works behind the scenes to produce the required output in the JSP page. The class can accept attribute value from the calling JSP page and produces output accordingly.
2. Defining the Tag library descriptor: All tag handlers which actually produce the necessary output with individual tag names are included in a library are defined in a tld file called the tag library descriptor.
3. Using of custom tags in JSP file:

A tag library is a collection of custom tags.
Custom actions are invoked using custom tags which are reusable modules to perform actions like form processing, accessing databases , email and directories, and flow control.
Java beans were used previously for these purposes.

Features include:

. can be customized via attributes passed from the calling page.
. have access to all the objects available to JSP pages.
. can modify the response generated by the calling page.
. can communicate with each other.

Types of Tags
Simple tags: Tags with no body or attributes. Directly invokes an action.

Tags with attributes: The start tag can contain attributes in the form attr="value".
Attributes help customize the behavior of a tag just as parameters are used to affect the outcome of executing a method on an object.
Ex: " />

Tags with a body

Tags That Define Scripting Variables

Cooperating Tags

No comments: