You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2003/02/13 18:36:51 UTC

DO NOT REPLY [Bug 17052] New: - jsp:element name attribute clobbered by nested jsp:attribute

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17052>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17052

jsp:element name attribute clobbered by nested jsp:attribute

           Summary: jsp:element name attribute clobbered by nested
                    jsp:attribute
           Product: Tomcat 5
           Version: 5.0.0
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Jasper2
        AssignedTo: tomcat-dev@jakarta.apache.org
        ReportedBy: Phil.Hanna@sas.com


If a <jsp:element> has a nested <jsp:attribute name="name">, the
<jsp:attribute> body is erroneously used as the tag name of the
generated element.

The JSP 2.0 spec JSP.5.14 says:

   A jsp:element element has one mandatory
   attribute, name, of type String. The value of
   the attribute is used as that of the tag of the
   element generated.

In other words,

   <jsp:element name="foo">
      <jsp:attribute name="bar">yada</jsp:attribute>
   </jsp:element>

generates this:

   <foo bar="yada"/>

However, if the attribute's name happens to be "name", the tag
name gets clobbered. Hence for this coding:

   <jsp:element name="input">
      <jsp:attribute name="type">text</jsp:attribute>
      <jsp:attribute name="name">userName</jsp:attribute>
   </jsp:element>

instead of this:

   <input type="text" name="userName" size="20"/>

it generates this:

   <userName type="text" size="20"/>

This makes it impossible with XML syntax to generate HTML forms,
that use named input elements.

--- Suggested Fix ---

The affected classes are in the org.apache.jasper.compiler package:

   Generator.java
   Node.java

In the Generator class, in the method

   public void visit(Node.JspElement n)

the code currently has special handling for any attribute named
"name", making it the tag name and excluding it from the rest of
the attribute generation.  This appears to be wrong to me, as it
confuses <jsp:attribute name="name"> and <jsp:element
name="foo">, and it makes it impossible to create <input
type="text" name="foo"/>, as noted above.

I think the fix would involve:

   1. In Node.java: add a "name" property to the Node.JspElement
      class, corresponding to the "name" attribute of the
      <jsp:element> standard action. In the constructor, extract
      the required "name" attribute passed in the first
      parameter, and store it as the value of the name property. 

   2. In Generator.java: In the visit(Node.JspElement n) method,
      take out the special handling, just using the
      Node.JspElement "name" property as the tag name,
      and allowing *all* Node.JspAttribute elements to
      contribute to the tag attributes without skipping "name".

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org