About Question enthuware.jwpv6.2.864 :

Moderator: admin

Post Reply
goetz
Posts: 11
Joined: Wed Jan 18, 2012 8:32 am
Contact:

About Question enthuware.jwpv6.2.864 :

Post by goetz »

Code: Select all

${requestScope['none'] eq 0}
returns false in both GlassFish 3.1 and Tomcat 7. I don't know why...

alex

Re: About Question enthuware.jwpv6.2.864 :

Post by alex »

both

Code: Select all

${none gt -1}

Code: Select all

${requestScope['none'] eq 0}
return false in Tomcat 7.0.32

admin
Site Admin
Posts: 10384
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.jwpv6.2.864 :

Post by admin »

As given in the explanation, the specification is very clear on this. A null is converted to a 0 (Section 1.18.3). So the implementations are not compliant in this case.

HTH,
Paul.

stoyants

Re: About Question enthuware.jwpv6.2.864 :

Post by stoyants »

Yes, Chapter 1.18.3 of specification states: "If A is null or "", return 0."
But, in case of null, this does not apply, as type conversion should not be executed at all.
Chapter 1.8.1 (about relational operators) states: "If A is null or B is null, return false"

Nevertheless, looks like Tomcat does not implement specification correctly, as in the case of question 2.864 value of requestScope['none'] is empty String and then conversion rule 1.18.3 should apply.

JoeAllen
Posts: 13
Joined: Thu Jul 11, 2013 11:22 pm
Contact:

Re: About Question enthuware.jwpv6.2.864 :

Post by JoeAllen »

Is ${requestScope['none'] eq 0} the same as ${requestScope[none] eq 0} in this case, since [none] is evaluated to ""?
By the way, have you been able to access coderanch.com these day? I have not. Wonder what happened to it.

admin
Site Admin
Posts: 10384
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.jwpv6.2.864 :

Post by admin »

In case of requestScope['none'], the string "none" is passed as a parameter to requestScope but in case of requestScope[none], you are trying to pass the value of the variable named none, which, in this case, doesn't exist so it evaluates to null. So the end result is same but they are not exactly same.

Please see section 1.6 of EL specification for further details.

HTH,
Paul.

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests