• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

String Operators in EL

 
deepak adlakha
Ranch Hand
Posts: 325
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

EL code
-----------------------------------
${"a"+2}
OUTPUT = 3
-----------------------------------

Normal Scripting
----------------------------------
<%
out.println("1"+2);
%>

OUTPUT :- 12
----------------------------------

Can someone tell me why there is difference in output?... isn't it should be same
[ June 04, 2007: Message edited by: deepak adlakha ]
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
${"a"+2}
OUTPUT = 3

Really ? Did you mean ${"1"+2} ?
EL treats arithmetic operations as "arithmetic", not string concatenation. The rule is then different from Java.
With an addition, the container tries to convert both arguments into numbers, and sums them up.
 
deepak adlakha
Ranch Hand
Posts: 325
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yup i meant ${"1"+2} only.

Thanks for explaination. But why it treats different as compare to java ?
 
Manoj Paul
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[Thread hijack removed]
[ June 04, 2007: Message edited by: Bear Bibeault ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic