Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!

# Doubt in EL operator

Gurukant Desai
Ranch Hand
Posts: 56
Hi,
While appearing in Marcus Green's quiz question no.5 of EL chapter
<%int i = 1;int j =2;%>
\${i < j}
\${1 lt 2}

I was expecting answer as "true true" but right answer is "false true"

Can anyone please explain why \${i < j} will evaluate to false?

[ May 06, 2008: Message edited by: Gurukant Desai ]

Musab Al-Rawi
Ranch Hand
Posts: 231
hi,

if i am not mistaken
<%int i = 1;int j =2;%>
these are variables not attributes. with the EL you can access attributes of four scopes.
so \${i} and \${j} are not defined ... so they are treated as zero.
So \${0 < 0} that's false because zero is equal to zero.

Ranch Hand
Posts: 437
Hi,
Any correct solutions to the problem?

Kumar Garlapati
Ranch Hand
Posts: 38
Musab is absolutely correct with bit change in the explaination, except that zero, it doesn't evaluates as zero. It evaluates as blank.

If it evaluates as zero, \${i==j}, should return true, but it's returning as false. i tried.

output is : true
If we remove scriplet from above code, then output is : false.
it means that if i and j are not present in any scope, they are unable to evaluate as any values. so its evaluating as false.
[ May 06, 2008: Message edited by: Kumar Garlapati ]

Musab Al-Rawi
Ranch Hand
Posts: 231
with EL null evaluates to false in boolean expressions and to zero in arithmetic operations.