tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 51490] if.jsp has many bugs and c:if example not useful
Date Fri, 08 Jul 2011 21:00:56 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=51490

--- Comment #4 from charles@everspeech.com 2011-07-08 21:00:56 UTC ---
Hi Christopher,
Thanks for looking at this!

For (1), I hope that the example is updated at some point in the near future.

For (2):
===== Begin Original if.jsp output ===
Tag Plugin Examples - <c:if>

Plugin Introductory Notes
Brief Instructions for Writing Plugins


Set the test result to a variable
The result of testing for (1==1) is: true
Conditionally execute the body
It's true that (2>0)! 
===== End Original if.jsp output ===

Now we look on the web and see that the taglib line can be replaced with an
xmlns:c attribute: xmlns:c="http://java.sun.com/jsp/jstl/core".
We delete the taglib line and add the attribute.
See if-bogus.jsp attached ("Modified example illustrating the issues").

If we visit if-bogus.jsp, the output is exactly the same as above!
If we restart Tomcat and visit if-bogus.jsp, then the output is exactly the
same again!
If we refresh the page, we finally get something slightly different
(the "true" disappears, but the "2>0" line remains):
===== Begin if-bogus.jsp output =====
Tag Plugin Examples - <c:if>

Plugin Introductory Notes
Brief Instructions for Writing Plugins


Set the test result to a variable
The result of testing for (1==1) is:
Conditionally execute the body
It's true that (2>0)! 
===== End if-bogus.jsp output =====

If we visit if.jsp again, it sets the "theTruth" session variable.
Now if we go back to if-bogus.jsp and refresh, it looks exactly like the
"Original if.jsp output" - it looks like it's working, but it's not.

I sent an updated if.jsp in the first attachment.
This fixes HTML issues and makes it clear when things are actually working:
1) Use scope="page" to avoid side effects from other example pages
2) Use a c:if that actually depends on JSTL working.

The output of the updated if.jsp example is exactly the same as before, but
only if things are working.

Here is the output from if-xmlns.jsp (same as if-bogus.jsp except based on the
updated if.jsp example):

===== Begin if-xmlns.jsp output =====
Tag Plugin Examples - <c:if>

Plugin Introductory Notes>
Brief Instructions for Writing Plugins


Set the test result to a variable
The result of testing for (1==1) is:
Conditionally execute the body
It's true that (2>0)!
If you see this, then (0>2)! Fail! 
===== Begin if-xmlns.jsp output =====

In the above output, note that
1) the "true" is not there (as expected)
2) the misleading (2>0) line is still there, but
3) a new line gets printed indicating that it's not actually working

New note:
Apparently, a scope="session" variable will be used by a scope="page" variable
of the same name.

After restarting Tomcat, then it's possible to switch between the updated
if.jsp and if-xmlns.jsp and the output will not change (no side effects, but a
restart is required as explained in "new note" above).

I agree with your note on (3) regarding failure to use JSTL properly.
Note that updating the example will help tremendously with (3)!
Currently, people look at the web, create something like if-xmlns.jsp, and then
think (at first) that it's working.

(4) the if-xmlns-works-after-if-but-not-before problem
This is just a scoping issue for "theTruth" as pointed out and as corrected in
the updated if.jsp example.

I hope that this helps.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message