Bug 48701 - jsp:getProperty broken for certain cases
jsp:getProperty broken for certain cases
Product: Tomcat 6
Classification: Unclassified
Component: Jasper
PC Linux
: P2 regression (vote)
: default
Assigned To: Tomcat Developers Mailing List
: 47822 (view as bug list)
Depends on:
  Show dependency tree
Reported: 2010-02-08 07:02 UTC by Boris Folgmann
Modified: 2014-02-17 13:51 UTC (History)
1 user (show)


Note You need to log in before you can comment on or make changes to this bug.
Description Boris Folgmann 2010-02-08 07:02:56 UTC
I've updated from tomcat6-6.0.18-9.jpp5 to tomcat6-6.0.24-2.jpp5

This breaks a lot of JSPs! Jasper simply denies to compile them. I hunted down the bug to a very simple example:

<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<c:set var="now" value='<%= new java.util.Date() %>' />
<jsp:getProperty name="now" property="time" />

This will simply output the current unix time (e.g. 1265641020987).
On tomcat 6.0.24 I get this:

org.apache.jasper.JasperException: jsp:getProperty for bean with name 'now'. Name was not previously introduced as per JSP.5.3
	at org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1083)
	at org.apache.jasper.compiler.Node$GetProperty.accept(Node.java:1124)
	at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2361)
	at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2411)
	at org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2417)
	at org.apache.jasper.compiler.Node$Root.accept(Node.java:495)
	at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2361)
	at org.apache.jasper.compiler.Generator.generate(Generator.java:3383)
	at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:216)
	at org.apache.jasper.compiler.Compiler.compile(Compiler.java:332)
	at org.apache.jasper.compiler.Compiler.compile(Compiler.java:312)
	at org.apache.jasper.compiler.Compiler.compile(Compiler.java:299)
	at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:589)
	at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

My JDK is
java version "1.6.0_17"
Java(TM) SE Runtime Environment (build 1.6.0_17-b04)
Java HotSpot(TM) Server VM (build 14.3-b01, mixed mode)

Please fix that! I assume that a lot of apps will break out there ...
Comment 1 Boris Folgmann 2010-02-08 07:29:50 UTC
To make it even more clear, this works:

<jsp:useBean id="now" class="java.util.Date" />
<jsp:getProperty name="now" property="time" />

But getProperty always fails when the bean is not created with useBean. It's not specific to <c:set>. Other constructions also fail.
Comment 2 Mark Thomas 2010-02-08 07:39:12 UTC
As per the error message at the beginning of the stack trace, the JSP is not valid.
Comment 3 Kris Schneider 2010-02-08 07:47:42 UTC
(In reply to comment #2)
> As per the error message at the beginning of the stack trace, the JSP is not
> valid.

I'll just add that <c:set> does not create a scripting variable, it creates a scoped variable. Here's part of the spec section referenced in the stack trace (JSP.5.3):

The object named by the name must have been “introduced” to the JSP processor using either the jsp:useBean action or a custom action with an associated VariableInfo entry for this name. If the object was not introduced in this manner, the container implementation is recommended (but not required) to raise a translation error, since the page implementation is in violation of the specification.

Looks like that's what's happening...
Comment 4 Boris Folgmann 2010-02-08 08:29:26 UTC
That's really bad because that worked up to 6.0.18. I can't remember any problems with such JSPs since tomcat 4 and 5. What about a compatibility switch to keep all that 3rd party apps from breaking?
Comment 5 Konstantin Kolinko 2010-02-15 17:14:25 UTC

Reviewing implementation of o.a.j.compiler.ScriptingVariabler and what the specification says about objects, scripting variables, and introducing them:

1. In Tomcat code we make no distinction between variables declared programmatically (through VariableInfo) and through TLD (TagVariableInfo).

Both introduce a java language variable (aka scripting variable) in the generated code.

From JSP.7.1.2 of JSP/2.2 spec:

"Finally, the XML document is processed to create a JSP page implementation
class. This process may involve creating scripting variables. Each custom action
will provide information about variables, either statically in the TLD, or more
flexibly by using the getVariableInfo method of a TagExtraInfo class."

- both ways introduce a variable

2. About the wording of JSP.5.3 I think that
There is no explicit requirement in the Spec to use TagVariableInfo to implement variables introduced through TLD at the time when we are generating the servlet code.  Thus I think the spec mentions VariableInfo in JSP.5.3, making no distinction.  Also maybe the wording was remained intact since JSP/1.1, and variable declarations in TLDs were introduced in JSP/1.2.

The place to fix this issue would be
- see "JSP.5.3" mentioned in a comment there
Comment 6 Mark Thomas 2010-03-08 21:55:43 UTC
Agreed. TagVariableInfo should be just as acceptable for this purpose.

I have fixed this in trunk and proposed it for 6.0.x
Comment 7 Konstantin Kolinko 2010-03-09 14:27:48 UTC
In r920880 of trunk I added a system property to allow disabling enforcement of JSP.5.3. This is proposed for 6.0 and 5.5.
Comment 8 Konstantin Kolinko 2010-03-09 14:30:47 UTC
*** Bug 47822 has been marked as a duplicate of this bug. ***
Comment 9 Mark Thomas 2010-04-10 21:40:09 UTC
This has been applied to 5.5.x and will be included in 5.5.30 onwards.
Comment 10 Mark Thomas 2010-04-10 21:48:11 UTC
This has been applied to 5.5.x and will be included in 5.5.30 onwards.
Comment 11 Mark Thomas 2010-04-11 09:39:38 UTC
The patch has been applied to 6.0.x and will be included in 6.0.27 onwards.
Comment 12 Kevin 2010-08-11 15:44:50 UTC
Still seeing this after upgrading to 6.0.29...

org.apache.jasper.JasperException: jsp:getProperty for bean with name 'auth'. Name was not previously introduced as per JSP.5.3
        at org.apache.tools.ant.ProjectHelper.addLocationToBuildException(ProjectHelper.java:574)
        at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:422)
        at org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:144)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:306)
        at org.apache.tools.ant.Task.perform(Task.java:401)
        at org.apache.tools.ant.Target.execute(Target.java:338)
        at org.apache.tools.ant.Target.performTasks(Target.java:365)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1237)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1094)
        at org.apache.tools.ant.Main.runBuild(Main.java:669)
        at org.apache.tools.ant.Main.startAnt(Main.java:220)
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:215)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:90)
Comment 13 Konstantin Kolinko 2010-08-11 18:04:07 UTC
(In reply to comment #12)
Are you sure, that your jsp page is valid? If you are, please attach a war file with a sample web application that reproduces the issue.

Note, that since 5.5.30 and 6.0.27 (as already is mentioned) you can disable the check for conformance with JSP.5.3. by defining a certain system property.


I am re-closing this as FIXED.