Posts

Showing posts from September, 2015

how to use JSP Custom Tag

Image
Example of JSP Custom Tag Example of JSP Custom Tag Create the Tag handler class Create the TLD file Create the JSP file In this example, we are going to create a  custom tag that prints the current date and time . We are performing action at the start of tag. 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 Understanding flow of custom tag in jsp 1) Create the Tag handler class To create the Tag Handler, we are inheriting the  TagSupport class  and overriding its method  doStartTag() .To write data for the jsp, we need to use the  JspWriter class . The  PageContext  class provides  getOut()  method that returns the instance of JspWriter class. TagSupport class provides instance of pageContext bydefault. File: MyTagHandler.