You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by BugRat Mail System <to...@cortexity.com> on 2000/09/15 16:01:32 UTC

BugRat Report #121 has been filed.

Bug report #121 has just been filed.

You can view the report at the following URL:

   <http://znutar.cortexity.com:8888/BugRatViewer/ShowReport/121>

REPORT #121 Details.

Project: Tomcat
Category: Bug Report
SubCategory: New Bug Report
Class: swbug
State: received
Priority: medium
Severity: serious
Confidence: public
Environment: 
   Release: 3.1
   JVM Release: 1.2.2
   Operating System: RedHat Linux
   OS Release: 6.1
   Platform: Pentium III

Synopsis: 
JSP Translation problem causing inconsistent <jsp:getProperty> behaviour

Description:
After moving some JSP code from Websphere to TomCat, I noticed a major inconsistency in behaviour. In both cases, only JSP1.0 features were used.

The problem arises when an object is created using the <jsp:useBean> tag, but the corresponding scripting variable is subsequently assigned a new Bean (of the same class).

In theory, using the <jsp:getProperty> tag should yield the current value of the given property of the named object. However, after assigning a new value to the scripting variable, the tag continues to return the value of the original object.

On the other hand, using the corresponding getProperty method of the scripting variable directly yields the expected results.

The problem seems to arise in the JSP Translator, as examination of the generated code (in a subdierctory of the work directory) shows.

When the <jsp:useBean> tag is translated, an object is instantiated and assigned to a named variable, AND a named reference is placed in the pageContext.

When a <jsp:getProperty> tag is translated, code is generated to obtain the reference from the pageContext and call the corresponding getProperty method:-

out.print(JspRuntimeLibrary.toString((((HasBeanpageContext.findAttribute("person")).getName())))



When a "direct" getProperty scriptlet is encountered, this is translated as a direct call on the named variable:-

out.print(person.getName())



Now, initially, these turn out to be one and the same thing, so the result is the same.

However, when a new object is assigned to the named variable, the reference in the pageContext is NOT correspondingly changed, thereby leading to different results.

The JSP1.1 spec is not compeletely unambiguous on this matter, but "common sense" would dictate that this behaviour is inconsistent and thereby confusing.