Custom tags are
user-defined tags. They eliminates the possibility of scriptlet tag and
separates the business logic from the JSP page.
Advantages of Custom Tags
The key advantages of Custom tags are as follows:
- Eliminates the need of scriptlet tag The
     custom tags eliminates the need of scriptlet tag which is considered bad
     programming approach in JSP.
 - Separation of business logic from
     JSP The
     custom tags separate the the business logic from the JSP page so that it
     may be easy to maintain.
 - Re-usability The
     custom tags makes the possibility to reuse the same business logic again
     and again.
 
Syntax to use custom tag
There are two ways to use the custom tag. They are given below:
<prefix:tagname attr1=value1....attrn=valuen />  
<prefix:tagname attr1=value1....attrn=valuen >  
body code  
</prefix:tagname>  
For
creating any custom tag, we need to follow following steps:
ü  Create
the Tag handler class and perform action at the start or at the end
of the tag.
ü  Create
the Tag Library Descriptor (TLD) file and
define tags
ü  Create the JSP file that uses the Custom tag defined in the TLD file
0 comments:
Post a Comment