Java Tutorial/JSP/JSP 2.0
Содержание
JSP 2.0 Expression Language - Basic Arithmetic
<source lang="java">
<html>
<head> <title>JSP 2.0 Expression Language - Basic Arithmetic</title> </head> <body>
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.
<thead>
EL Expression Result </thead>
\${1} ${1} \${1 + 2} ${1 + 2} \${1.2 + 2.3} ${1.2 + 2.3} \${1.2E4 + 1.4} ${1.2E4 + 1.4} \${-4 - 2} ${-4 - 2} \${21 * 2} ${21 * 2} \${3/4} ${3/4} \${3 div 4} ${3 div 4} \${3/0} ${3/0} \${10%4} ${10%4} \${10 mod 4} ${10 mod 4} \${(1==2) ? 3 : 4} ${(1==2) ? 3 : 4}
</body>
</html></source>
JSP 2.0 Expression Language - Basic Comparisons
<source lang="java">
<html>
<head> <title>JSP 2.0 Expression Language - Basic Comparisons</title> </head> <body>
JSP 2.0 Expression Language - Basic Comparisons
This example illustrates basic Expression Language comparisons. The following comparison operators are supported:
- Less-than (< or lt)
- Greater-than (> or gt)
- Less-than-or-equal (<= or le)
- Greater-than-or-equal (>= or ge)
- Equal (== or eq)
- Not Equal (!= or ne)
Numeric
<thead>
EL Expression Result </thead>
\${1 < 2} ${1 < 2} \${1 lt 2} ${1 lt 2} \${1 > (4/2)} ${1 > (4/2)} \${1 > (4/2)} ${1 > (4/2)} \${4.0 >= 3} ${4.0 >= 3} \${4.0 ge 3} ${4.0 ge 3} \${4 <= 3} ${4 <= 3} \${4 le 3} ${4 le 3} \${100.0 == 100} ${100.0 == 100} \${100.0 eq 100} ${100.0 eq 100} \${(10*10) != 100} ${(10*10) != 100} \${(10*10) ne 100} ${(10*10) ne 100}
Alphabetic
<thead>
EL Expression Result </thead>
\${"a" < "b"} ${"a" < "b"} \${"hip" > "hit"} ${"hip" > "hit"} \${"4" > 3} ${"4" > 3}
</body>
</html></source>