Bug 54144 - Processing of java.io.Reader in "Out" tagplugin
Summary: Processing of java.io.Reader in "Out" tagplugin
Alias: None
Product: Tomcat 7
Classification: Unclassified
Component: Jasper (show other bugs)
Version: 7.0.32
Hardware: PC Windows XP
: P2 minor (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
Depends on:
Reported: 2012-11-14 08:38 UTC by Konstantin Kolinko
Modified: 2012-11-17 00:01 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description Konstantin Kolinko 2012-11-14 08:38:29 UTC
Reviewing r1401816 I see two issues in tagplugin o.a.jasper.tagplugins.jstl.core.Out:

The code that the plugin generates calls value.toString(), default.toString() and passes these String values to the static method Out.output(...). This new method was added in r1401816.

I think the output() method should accept Objects instead of Strings, because the following is wrong:

1. The evaluation of default.toString() is not needed at all if the default is not used.

2. The JSTL spec (1.1, 1.2) says that there is special processing if value is java.io.Reader. There is no such processing in the current code. (It seems that this feature was added in JSTL 1.1).

If the result of the evaluation is not a java.io.Reader object, then it is coerced to
a String and is subsequently emitted into the current JspWriter object.

If the result of the evaluation is a java.io.Reader object, data is first read from the
Reader object and then written into the current JspWriter object.

These two issues are not new - they existed before the recent changes.
Comment 1 Konstantin Kolinko 2012-11-15 05:03:00 UTC
3. JSTL spec says (under "Null & Error Handling"):
"If no default value is specified, it itself defaults to an empty string."

In the current code:
a) A null is used instead of "" as the value of strDefName.
b) I suspect that the following check for "no default value specified" is incorrect:
            ctxt.generateJavaSource(" != null){");

One has to check whether the attribute is present, instead of checking whether its value is null.
Comment 2 Konstantin Kolinko 2012-11-15 08:48:09 UTC
(In reply to comment #1)
> One has to check whether the attribute is present, instead of checking
> whether its value is null.

Actually checking for null should be OK here. Apache implementation of JSTL tests for null there. "if (def != null)" on line 100 in

4. If default is not specified, the body of the tag has to be used as the default value. This feature was completely broken by r1401816 as the following lines were removed:

-        ctxt.generateJavaSource("    }else{");
-        ctxt.generateBody();
-        ctxt.generateJavaSource("    }");
Comment 3 Mark Thomas 2012-11-16 22:49:51 UTC
I've fixed using body as the default issue in trunk and 7.0.x.
Comment 4 Mark Thomas 2012-11-17 00:01:53 UTC
Fixed in trunk and 7.0.x and will be included in 7.0.33 onwards.