Javatpoint Logo
Javatpoint Logo

Attributes in JSP Custom Tag

There can be defined too many attributes for any custom tag. To define the attribute, you need to perform two tasks:

  • Define the property in the TagHandler class with the attribute name and define the setter method
  • define the attribute element inside the tag element in the TLD file

Let's understand the attribute by the tag given below:

Here m is the prefix, cube is the tag name and number is the attribute.

Simple example of attribute in JSP Custom Tag

In this example, we are going to use the cube tag which return the cube of any given number. Here, we are defining the number attribute for the cube tag. We are using the three file here:

  • index.jsp
  • mytags.tld


JSP Custom Tag attribute example with database

Let's create a custom tag that prints a particular record of table for the given table name and id.

So, you have to have two properties in the tag handler class.


jsp custom tag attribute example/>

<div id= download this example

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA