This week's book giveaway is in the Java in General forum.
We're giving away four copies of Event Streams in Action and have Alexander Dean & Valentin Crettaz on-line!
See this thread for details.
Win a copy of Event Streams in Action this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

EL "" will it be interpreted as zero ?

 
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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




 
Ranch Hand
Posts: 336
Firefox Browser Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have to test this for exam purpose.
 
Milton Ochoa
Ranch Hand
Posts: 336
Firefox Browser Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am preparing for the exam too.

are you taking a simulator? mock exam?
 
Kathiresan Chinna
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I am reading HFSJ book and practise from that question.
 
Milton Ochoa
Ranch Hand
Posts: 336
Firefox Browser Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 Rahman
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

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

Kathir
 
Abdul Rahman
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!