In an application, you can define custom JSP tag libraries using tag library definition (TLD) files.
A TLD file is an XML-style document that defines a tag library and its individual tags and
has a .tld extension.
TLD attribute names must have a matching setter method in the custom tag class. The getter method is optional. When you move a custom tag library from other application servers, migration problems can occur if the method names do not match the attribute name correctly and the other application server ignores case matching or does not fully validate the names.
This rule scans TLD files and compares attribute names to the method names in the corresponding
tag class. The rule flags attributes where a matching setter method is not found
or the getter method is found but the case does not match correctly.
For example, an attribute named attr should have a
corresponding method called setAttr and an optional
method called getAttr.
The following table includes more examples of matching names:
| Attribute name | Getter method name | Setter method name |
|---|---|---|
| attr | getAttr | setAttr |
| UPPERAttr | getUPPERAttr | setUPPERAttr |
| Attr | no valid getter | no valid setter |
For the rule to find the getter and setter methods that match the attribute, it changes the first letter
after the get or set to its lowercase value and matches the rest of the name to an attribute name.
If a method has more than one uppercase letter after the get or set,
the attribute name is not expected to be lowercase.
This algorithm means that an attribute that has a single uppercase letter can never match a method.
If you find a mismatch, you can fix the Java getter and setter methods or you can change the TLD definition to match. If your JSP files match the TLD files correctly, changing the getter and setter methods to match names in the TLD files is the simplest approach to fixing the problem. If you change the names in the TLD file, you must also update the JSP files that use the changed tags. After you change any TLD files, run the Use correct case for tag attribute names rule again to validate the attributes.