https://issues.apache.org/bugzilla/show_bug.cgi?id=56516

            Bug ID: 56516
           Summary: VariableInfo doesn't handle scope changes correctly
           Product: Tomcat 7
           Version: 7.0.53
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Jasper
          Assignee: dev@tomcat.apache.org
          Reporter: ad...@moparisthebest.com

Created attachment 31609
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=31609&action=edit
zip containing test case

Basically the problem is that when VariableInfo is returned from a
TagExtraInfo, the variable is declared once in the generated .java file and
never again.  If any scope changes happen, like a try/catch, if/else etc etc,
the variable isn't declared in subsequent scopes, and it won't compile.

quick example, generates this:
try{
java.lang.String message = null;
// initialize tag
message = (java.lang.String) _jspx_page_context.findAttribute("message");
} catch(Exception e) {
// initialize tag
message = (java.lang.String) _jspx_page_context.findAttribute("message"); //
error here, message not declared in scope
}

should generate this:
try{
java.lang.String message = null;
// initialize tag
message = (java.lang.String) _jspx_page_context.findAttribute("message");
} catch(Exception e) {
java.lang.String message = null;
// initialize tag
message = (java.lang.String) _jspx_page_context.findAttribute("message");
}

 I am attaching all files required for a test case as a single zip file:

./com/taglib/HelloTag.java - example tag
./com/taglib/HelloExtraInfo.java - example tag extra info
./hello.tld - example tld
./badtomcat.jsp - example jsp
./badtomcat_jsp.java - incorrect generated java code for example jsp

Let me know if you have any more questions.

-- 
You are receiving this mail because:
You are the assignee for the bug.

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

Reply via email to