• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

EL String conversion

 
Kathiresan Chinna
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

Consider the following EL

${ "-2" < -1 } --> true
${ "-2" < "-1" } --> false

It seems the first convert to negative but second is not.
Can someone explain how this is evaluated ?

Thanks
Kathir
 
Kathiresan Chinna
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also,

{ "-1" > "-2" } --> false

Regards
Kathir
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check the rules in the JSP specification, JSP.2.3.5.6 A {<,>,<=,>=,lt,gt,le,ge} B.

${ "-2" < -1 }
-1 is considered to be a number so "-2" will be converted to Long, and both Long will be compared : -2 < -1 : true.

${ "-2" < "-1" }
Both are Strings, so they will be compared lexically. "-2" < "-1" = "2" < "1" = false.
 
Kathiresan Chinna
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Great
Thank you
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic