Mantis - Resin
Viewing Issue Advanced Details
387 minor always 09-16-05 00:00 11-30-05 14:42
user391  
 
normal  
closed 3.0.14  
3.0.14 fixed  
none    
none 3.0.15  
0000387: Cannot create JSP 2.0 .tag file with "class" attribute
RSN-433
Given the following JSP 2.0 tag file:

---
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" [^] %>
<%@ attribute name="url" required="true"%>
<%@ attribute name="class" required="false"%>
<%@ attribute name="width" required="false"%>
<%@ attribute name="height" required="false"%>

<c:if test="${empty width}"><c:set var="width" value="600"/></c:if>
<c:if test="${empty height}"><c:set var="height" value="400"/></c:if>

<a href="openPopup('${url}', 'popup', 'width=${width},height=${height},directories=no,location=no,menubar=no,status=no,toolbar=no')"><jsp:doBody/></a>
---

This will result in a compilation error because of the name of the attribute "class" which is a reserved word in Java:

<identifier> expected
  private java.lang.String class;

This is because names of attributes are copied verbatim as members of the implementing class. No check for reserved words is done. A solution would be to append a '_' to every member, but with proper setters:

public void setClass(String class_) {
    this.class_ = class_;
}

If I change the attribute name to "className" everything works as expected.
Windows XP SP2, Java 1.5

Notes
(0000445)
ferg   
09-16-05 00:00   
jsp/101f