Bug 12989 - JSTL "c:out" uses body-default, even if value is not NULL or ""
Summary: JSTL "c:out" uses body-default, even if value is not NULL or ""
Status: RESOLVED DUPLICATE of bug 16069
Alias: None
Product: Taglibs
Classification: Unclassified
Component: Standard Taglib (show other bugs)
Version: 1.1
Hardware: PC All
: P3 critical with 3 votes (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-09-25 07:43 UTC by Nathanael Obermayer
Modified: 2005-03-20 17:06 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nathanael Obermayer 2002-09-25 07:43:26 UTC
JSTL "c:out" uses body-default, even if value is not NULL or "".

the error is easy to test:
copy the standard-examples.war from 
http://jakarta.apache.org/taglibs/doc/standard-doc/intro.html into your webapps-
directory, and open this url: http://127.0.0.1:8080/standard-
examples/elsupport/Out.jsp

you can see the source-code here: http://127.0.0.1:8080/standard-
examples/ShowSource.jsp?filename=/elsupport/Out.jsp

"Howe" has a cell-phone-number and the string "no cell phone specified"... 
thats the bug.

the error doesn't occur in bea weblogic 6.1

thanks for your help!!
greeting,
nathanael
Comment 1 Vit Timchishin 2003-02-06 09:34:15 UTC
Actually there are two problems here:
1) Jasper one - if tag implements body tag support and sometimes body is empty
and sometimes not, then we may have next problem:
a)Tag uses body (bodyContent set)
b)Tag sent to pool (bodyContent set)
b)Tag uses empty body (old bodyContent set).
I've resolved this by setting bodyContent attribute to null before sending tag
to pool:
Generator.java, line 1440:
            if (ctxt.getOptions().isPoolingEnabled()) {
                //We must reset body before sending to pool if it was set before
                if (n.implementsBodyTag() && n.getBody() != null)
                {
                    out.printin(tagHandlerVar);
                    out.println(".setBodyContent(null);");
                }
                out.printin(n.getTagHandlerPoolName());
                out.print(".reuse(");
                out.print(tagHandlerVar);
                out.println(");");
            }
Comment 2 Vit Timchishin 2003-02-06 09:36:29 UTC
Second problem is with standart taglib: it uses needBody variable, but do not
resets it to false in StartTag ( and we may be NOT called release between uses)
Fix is: OutSupport.java, line 122:
    public int doStartTag() throws JspException {
      try {
        needBody = false;
        // print value if available; otherwise, try 'default'
        if (value != null) {
            out(pageContext, escapeXml, value.toString());
            return SKIP_BODY;
        } else {
Comment 3 Pierre Delisle 2003-02-06 18:36:55 UTC
This has been fixed for JSTL 1.0.3, currently available 
via the nightly builds.

*** This bug has been marked as a duplicate of 16069 ***