JSP 2.0 Expression Language - Basic Arithmetic
JSP 2.0 Expression Language - Basic Arithmetic
This example illustrates basic Expression Language arithmetic.
Addition (+), subtraction (-), multiplication (*), division (/ or div),
and modulus (% or mod) are all supported. Error conditions, like
division by zero, are handled gracefully.
EL Expression |
Result |
${1} |
1 |
${1 + 2} |
3 |
${1.2 + 2.3} |
3.5 |
${1.2E4 + 1.4} |
12001.4 |
${-4 - 2} |
-6 |
${21 * 2} |
42 |
${3/4} |
0.75 |
${3 div 4} |
0.75 |
${3/0} |
Infinity |
${10%4} |
2 |
${10 mod 4} |
2 |
${(1==2) ? 3 : 4} |
4 |