Sunday, October 10, 2010

JSP Custom Tag


JSP-Custom Tag

Introduction:
                        Custom tag is user-defined tag that enables us to minimize complex and repetitive business logic in jsp by creating the reusable components, which can be used in another application.

package:
                        javax.servlet.jsp.tagext;

Custom tag API:

Custom tag API consists of classes and interfaces of the javax.servlet.jsp.tagext that are used to create custom tag.

Interfaces:

1). Tag

2). IterationTag

3). BodyTag

Classes:

1). BodyContent

2). TagSupport

3). BodyTagSupport

4). TagData

5). TagInfo

6). TagLibraryInfo

7). TagVariableInfo         

Tag Interface


Tag Interface has many methods.

1). doStartTag()

2). doEndTag()

3). release()

4). setPageContext()

5). setParent()

6). getParent()



                                                            IterationTag



The IterationTag interface extends Tag Interface.


                           doAfterBody()

                           
                            Re-evaluation of the body content of custom tag

 

                                                           BodyTag



 

The BodyTag interface  extends IterationTag



This interface defines method that enable ag handler to manipulate the body content of custom tag.

1). doInitBody

2). setBodyContent()




Type of custom tag



1). Custom Tag- Empty Tag


2). Custom Tag- tag with Attributes


3). Custom Tag- tag with body


4). Custom Tag- nested Tags


No comments:

Post a Comment