Meaningless Drivel is fun!*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes EL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "EL "" will it be interpreted as zero ?" Watch "EL "" will it be interpreted as zero ?" New topic
Author

EL "" will it be interpreted as zero ?

Kathiresan Chinna
Ranch Hand

Joined: Aug 17, 2008
Posts: 115
Hi there,

See the following EL and return values

1. ${ "" > -1 } --> true
2. ${ "" > 0 } --> false
3. ${ "" == 0 } --> false
4. ${ "" < 1 } --> true

As per the JSp spec Coerce A to Number type N
• If A is null or "", return 0.

But the 3 is evaluated false.
Is this correct ?

Thanks in Advance
Kathiresan




Milton Ochoa
Ranch Hand

Joined: Oct 23, 2007
Posts: 336

very intesting your question,

but i wonder, why you got there, i mean, compare the "" sttring with number.

Maybe the comparation is about strings and not numbers.
Kathiresan Chinna
Ranch Hand

Joined: Aug 17, 2008
Posts: 115
I have to test this for exam purpose.
Milton Ochoa
Ranch Hand

Joined: Oct 23, 2007
Posts: 336

I am preparing for the exam too.

are you taking a simulator? mock exam?
Kathiresan Chinna
Ranch Hand

Joined: Aug 17, 2008
Posts: 115
Hi, I am reading HFSJ book and practise from that question.
Milton Ochoa
Ranch Hand

Joined: Oct 23, 2007
Posts: 336

on enthuware says on one answer.

...Since none is "", it will be interpreted as 0...


and none is declarated like String none = "";

but they mention (JSP 2.3.5.1) too. But there say nothing about that.
Abdul Rahman
Ranch Hand

Joined: Jul 04, 2008
Posts: 63
As per HFSJ 1st edition and as per JSP2.0 spec, for arithmetic operation, EL treats the null values as Zero.
For logical operation, EL treats null values as false.


Abdul
SCJP5, SCWCD5, [scwcd wall of fame]
Abdul Rahman
Ranch Hand

Joined: Jul 04, 2008
Posts: 63
As per HFSJ 1st edition and as per JSP2.0 spec, for arithmetic operation, EL treats the null values as Zero.
For logical operation, EL treats null values as false.
3. ${ "" == 0 } --> false

This will return true.
Kathiresan Chinna
Ranch Hand

Joined: Aug 17, 2008
Posts: 115
Hello,

I am using Tomcat 6.0.18
I got ${ "" == 0 } --> false

Kathir
Abdul Rahman
Ranch Hand

Joined: Jul 04, 2008
Posts: 63
Hi Kathy,
As per JSP2.0 spec and as per Tomcat5.0 (the one i'm using), i got that result to be true.
We'll have to look the jsp version supported by tomcat6. and the spec of that jsp version.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: EL "" will it be interpreted as zero ?
 
Similar Threads
Multiple Actions issue in JSF
Combo box hiding when using jQuery form transformation
Boolean value not changing
hashcode & equals - how to check array
Doubt in EL