Hello

I think there is a serious bug in the jsp compiler from tomcat 4.1.10.
The compiler creates wrong code for nested variables. Here an example
that works with 4.1.9 and does not with 4.1.10


JSP
---

<%@ taglib uri="/misc"  prefix="misc" %>
<html><head><title>Title</title></head><body>
<misc:test id="t">
<%= t %>
</misc:test>
</body></html>


TLD
---
  <tag>
    <name>test</name>
    <tag-class>TestTag</tag-class>
    <body-content>JSP</body-content>
    <variable>
      <name-from-attribute>id</name-from-attribute>
      <variable-class>java.lang.String</variable-class>
      <declare>true</declare>
      <scope>NESTED</scope>
    </variable>    
    <attribute>
      <name>id</name>
      <required>true</required>
      <rtexprvalue>true</rtexprvalue>
    </attribute>    
  </tag>   

CODE
----

public class TestTag extends TagSupport {

  private String id;
  public TestTag() {
    init();
  }
  public String getId() {
    return id;
  }
  public void setId(String id) {
    this.id = id;
  }
  public void release() {
    super.release();
    init();
  }
  private void init() {
    id = null;
  }
  public int doStartTag() throws JspException {
    pageContext.setAttribute(getId(), "a short test string", PageContext.PAGE_SCOPE); 
    return (EVAL_BODY_INCLUDE);
  }


Compiled JSP
------------
Here you can see what's wrong. The assignment for t is on the wrong
position

       if (_jspx_eval_misc_test_0 != javax.servlet.jsp.tagext.Tag.SKIP_BODY) {
===>        java.lang.String t = null;
        do {
          out.write("\r\n");
===>          out.print( t );
          out.write("\r\n");
          int evalDoAfterBody = _jspx_th_misc_test_0.doAfterBody();
===>          t = (java.lang.String) pageContext.findAttribute("t");
          if (evalDoAfterBody != javax.servlet.jsp.tagext.BodyTag.EVAL_BODY_AGAIN)
            break;
        } while (true);
      }


  
Regards
Ralph


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to