Summary: | Jasper creates duplicate variable names | ||
---|---|---|---|
Product: | Tomcat 6 | Reporter: | Stefan Birkner <Stefan.Birkner> |
Component: | Jasper | Assignee: | Tomcat Developers Mailing List <dev> |
Status: | RESOLVED FIXED | ||
Severity: | normal | ||
Priority: | P2 | ||
Version: | 6.0.0 | ||
Target Milestone: | default | ||
Hardware: | PC | ||
OS: | All | ||
Attachments: |
WAR of a test application to reproduce the bug
Patch to be applied to the package org.apache.jasper.compiler |
Description
Stefan Birkner
2008-08-26 07:23:33 UTC
Created attachment 22482 [details]
WAR of a test application to reproduce the bug
Here is a WAR, which can be used to replay the bug. After installing the war, you have to start your tomcat and a debugger. Then do the following steps:
* set a breakpoint on JspUtil.nextTemporaryVariableName()
* open /duplicateVariableName/test1.jsp in your browser
* your debugger stops at JspUtil.nextTemporaryVariableName()
* resume the debugger
* again your debugger stops at JspUtil.nextTemporaryVariableName()
* open /duplicateVariableName/test2.jsp in your browser
* your debugger stops at JspUtil.nextTemporaryVariableName()
* switch to the thread of /duplicateVariableName/test1.jsp
* resume the debugger
* the browser window of /duplicateVariableName/test1.jsp shows the error
Created attachment 22483 [details]
Patch to be applied to the package org.apache.jasper.compiler
This patch changes two classes: org.apache.jasper.compiler.Generator and org.apache.jasper.compiler.Node.
Instead of creating the variable names of NamedAtttributes when parsing the JSP code, the names are created when the Generator generates the java code.
The Generator class has two additional members: an HashMap<NamedAttribute, String> variableNamesOfNamedAttributes, which stores the mapping between NamedAttributes and there variable names, and a variableNameCounter, which is used to create the variables' names. The new method getVariableName(NamedAttribute) returns the variable names.
The member temporaryVariableName and its getter getTemporaryVariableName() are removed from the node class.
I have fixed this in trunk with a more general fix that should address all possible issues if this nature. The fix has been proposed for 6.0.x This has been applied to 6.0.x and will be included in 6.0.19 onwards. |