JSP custom tags

JSP custom tags are the user-defined following a special XML syntax to which JavaBean tags (useBean getProperty and setProperty) uses.

JSP custom tags

JSP custom tags

     

JSP custom tags are the user-defined following a special XML syntax to which JavaBean tags (useBean getProperty and setProperty) uses. When Servlet container processes the custom tag by invoking one or more Java class files, in much the same way that a Java class file is used to handle JavaBean calls for a JSP page. After processing the tag, the container pass it to one or more class files for handling simply by taking its name and attributes, as well as any content that may exist in the body of the tag. 

Implementing JSP custom tags

Following components are required to implement custom tags in the JSP architecture:

  • Each page requires a JSP declaration
  • Deployment Descriptor(web.xml) requires an entry
  •  special XML file and the Java classes contained in a JAR file that will be invoked to process the custom tags

This section meets these requirements and incorporate custom tags into your JSP pages. There are five steps required to implement a custom tag to implement into a JSP page

  1. Define a tag handler class.
  2. Define a tag library descriptor (TLD).
  3. Make an entry of this TLD file in the Deployment Descriptor.
  4. Reference the tag library.
  5. Use the tag in a JSP page.