aspose file tools*
The moose likes JSP and the fly likes String Operators in EL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "String Operators in EL" Watch "String Operators in EL" New topic
Author

String Operators in EL

deepak adlakha
Ranch Hand

Joined: Jul 27, 2001
Posts: 325
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

Joined: Nov 24, 2005
Posts: 14688
    
  16

${"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.


[My Blog]
All roads lead to JavaRanch
deepak adlakha
Ranch Hand

Joined: Jul 27, 2001
Posts: 325
yup i meant ${"1"+2} only.

Thanks for explaination. But why it treats different as compare to java ?
Manoj Paul
Ranch Hand

Joined: Jan 18, 2007
Posts: 112
[Thread hijack removed]
[ June 04, 2007: Message edited by: Bear Bibeault ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: String Operators in EL