What are the standard attributes that should be passed to a custom tag in a JSP page?



Consider including the following properties for an attribute −

S.No. Property & Purpose
1 name
The name element defines the name of an attribute. Each attribute name must be unique for a particular tag.
2 required
This specifies if this attribute is required or is an optional one. It would be false for optional.
3 rtexprvalue
Declares if a runtime expression value for a tag attribute is valid
4 type
Defines the Java class-type of this attribute. By default, it is assumed as String
5 description
Informational description can be provided.
6 fragment
Declares if this attribute value should be treated as a JspFragment.

Following is the example to specify properties related to an attribute −

.....
   <attribute>
      <name>attribute_name</name>
      <required>false</required>
      <type>java.util.Date</type>
      <fragment>false</fragment>
   </attribute>
.....

If you are using two attributes, then you can modify your TLD as follows −

.....
   <attribute>
      <name>attribute_name1</name>
      <required>false</required>
      <type>java.util.Boolean</type>
      <fragment>false</fragment>
   </attribute>

   <attribute>
      <name>attribute_name2</name>
      <required>true</required>
      <type>java.util.Date</type>
   </attribute>
.....
Updated on: 2019-07-30T22:30:25+05:30

77 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements