Procedure to Develop Custom JSP Tag Library – Struts Tutorial

Procedure to develop customer JSP tag library:-

Design tag library

             Ram tag library



Develop tag handler classes (in WEB-INF / classes)


               Public class ABC Tag extends TagSupport


                             ————– define the functionality of ABCTag.<ABC>


                    Public class xyz Tag extends TagSupport 



                         ————–   define the functionality of <xyz>


Develop .tld file for Tag library:


                  <ABC> ———> ABCTag

                 <xyz> ———-> xyzTag

     Step 1 – step 3 talks about the development of jsp tag library.

configure jsp tag library in web.xml file



                 <taglib-uri> demo </taglib-uri>

                <taglib-location> /WEB-INF/ Ram.tld </taglib-location>



Note: – Every jsp tag library configured in web xml file will be identified through its taglib-url (like demo of above code)

Use jsp tag library in our jsp programs:


           <%@taglib uri = “demo” prefix =”mr” %>

                 <mr: ABC i>


                <mr: xyz i>

(h): ào/p of <mr: ABC> goes to browser window.

Note: – In the above sample code step number @ – (h) indicates <mr: ABC> Tag related flow of execution.

Step configure jsp tag library in web.xml file, Use jsp tag library in our jsp programs talks about utilization of jsp tag library.

  • Every Tag of jsp tag library must be accessed through prefix. This prefixes word or letter or is programmer choice.
  • If two jsp tags of two different jsp tag libraries are having same name in order to use both the tags in a single jsp program we can differentiate then through prefixes.
  • Struts supplies 5 no. of built-in jsp tag libraries having set of jsp tags while working with these tag libraries we can make the jsp programs of struts application as java codeless jsp programs.

Tag library name         tld file        Recommended profile        jar files having tld files &  Tag handler classes

Html                               struts-html.tld               html                                  struts – taglib – 1.3.8.jar

Bean                              struts-bean.tld                bean                                 struts – taglib – 1.3.8.jar

Logic                              struts-logic.tld                logic                                  struts – taglib – 1.3.8.jar

Nested                          struts-nested.tld            nested                               struts – taglib – 1.3.8.jar

Tiles                               struts-tiles.tld                 tiles                                    struts – tiles – 1.3.8.jar

  • Developing jsp programs java codeless jsp programs is called as implementation of view helper design pattern.
  • The java classes’ jsp programs improve the readability of jsp programs.
  • To make jsp programs of struts application as java codeless jsp programs use the following tags.
  1. Struts supplied jsp tags
  2. Jstl tags
  3. Built-in action tags of jsp technology.
  4. html tags
  5. Customer tags
  • The struts-home \ does \ struts-taglib \ index.html file provides documentation about all the struts supplied jsp tag libraries.

Note: – Struts – taglib – 1.3.8. jar file, Struts – tiles – 1.3.8. jar files are available in Struts home \ lib folder.

  • The Struts supplied html tag library provides jsp tags alternate for plane traditional html tags.

Leave a Reply

Your email address will not be published. Required fields are marked *