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

JSPJava 8Object Oriented ProgrammingProgramming

Consider including the following properties for an attribute −

S.No.Property & Purpose
1name
The name element defines the name of an attribute. Each attribute name must be unique for a particular tag.
2required
This specifies if this attribute is required or is an optional one. It would be false for optional.
3rtexprvalue
Declares if a runtime expression value for a tag attribute is valid
4type
Defines the Java class-type of this attribute. By default, it is assumed as String
5description
Informational description can be provided.
6fragment
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>
.....
raja
Published on 20-Mar-2019 13:02:39
Advertisements