-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Dimitrius,

Dimitris Mouchritsas wrote:
> Christopher Schultz wrote:
>> You are adding the result of the ternary operator. The second
>> parameter to the ternary operator is a double value (0.0). The
>> third one is a String.
>
> Well shouldn't the result of the ternary operator depend on the test?

Yes: that's the problem. The compiler recognized that, if the second
branch of the ternary operator were evaluated, it would be trying to
perform an addition operation on (double, String), which doesn't make
any sense to it (best case scenario: you get a String like "4050"
instead of adding 40 and 50 to get 90).

Don't forget that the ternary operator isn't the only thing in play,
here: the result of that operation is being used. I'm pretty sure EL
gets translated loosely into Java code in the uncompiled java class, and
then a standard compiler goes from .java -> .class. If you tried to do
this in Java, you can see exactly why it wouldn't work:

double d = 3.14 + "-";

or even
String s = "3.14";
double d = 3.14 + ("-".equals(s) ? 0.0 : s);

Neither of these are compilable, so why would you expect them to work in EL?

The JSP -> .java compiler in Tomcat 6 must be more advanced and includes
more "do what I mean" logic. I hope the JSP compiler continues to agree
with what you "mean" in these situations ;)

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGuJbW9CaO5/Lv0PARAirCAJ9G0X4pRBnaFKlIpkt1HJUpQp+JXQCfVn4V
yRkhLWjTiptwOyMV+dco53w=
=Zr5b
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to