1 | <html><body><pre> |
---|
2 | <!-- |
---|
3 | Licensed to the Apache Software Foundation (ASF) under one or more |
---|
4 | contributor license agreements. See the NOTICE file distributed with |
---|
5 | this work for additional information regarding copyright ownership. |
---|
6 | The ASF licenses this file to You under the Apache License, Version 2.0 |
---|
7 | (the "License"); you may not use this file except in compliance with |
---|
8 | the License. You may obtain a copy of the License at |
---|
9 | |
---|
10 | http://www.apache.org/licenses/LICENSE-2.0 |
---|
11 | |
---|
12 | Unless required by applicable law or agreed to in writing, software |
---|
13 | distributed under the License is distributed on an "AS IS" BASIS, |
---|
14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
---|
15 | See the License for the specific language governing permissions and |
---|
16 | limitations under the License. |
---|
17 | --> |
---|
18 | <html> |
---|
19 | <head> |
---|
20 | <title>JSP 2.0 Expression Language - Basic Arithmetic</title> |
---|
21 | </head> |
---|
22 | <body> |
---|
23 | <h1>JSP 2.0 Expression Language - Basic Arithmetic</h1> |
---|
24 | <hr> |
---|
25 | This example illustrates basic Expression Language arithmetic. |
---|
26 | Addition (+), subtraction (-), multiplication (*), division (/ or div), |
---|
27 | and modulus (% or mod) are all supported. Error conditions, like |
---|
28 | division by zero, are handled gracefully. |
---|
29 | <br> |
---|
30 | <blockquote> |
---|
31 | <code> |
---|
32 | <table border="1"> |
---|
33 | <thead> |
---|
34 | <td><b>EL Expression</b></td> |
---|
35 | <td><b>Result</b></td> |
---|
36 | </thead> |
---|
37 | <tr> |
---|
38 | <td>\${1}</td> |
---|
39 | <td>${1}</td> |
---|
40 | </tr> |
---|
41 | <tr> |
---|
42 | <td>\${1 + 2}</td> |
---|
43 | <td>${1 + 2}</td> |
---|
44 | </tr> |
---|
45 | <tr> |
---|
46 | <td>\${1.2 + 2.3}</td> |
---|
47 | <td>${1.2 + 2.3}</td> |
---|
48 | </tr> |
---|
49 | <tr> |
---|
50 | <td>\${1.2E4 + 1.4}</td> |
---|
51 | <td>${1.2E4 + 1.4}</td> |
---|
52 | </tr> |
---|
53 | <tr> |
---|
54 | <td>\${-4 - 2}</td> |
---|
55 | <td>${-4 - 2}</td> |
---|
56 | </tr> |
---|
57 | <tr> |
---|
58 | <td>\${21 * 2}</td> |
---|
59 | <td>${21 * 2}</td> |
---|
60 | </tr> |
---|
61 | <tr> |
---|
62 | <td>\${3/4}</td> |
---|
63 | <td>${3/4}</td> |
---|
64 | </tr> |
---|
65 | <tr> |
---|
66 | <td>\${3 div 4}</td> |
---|
67 | <td>${3 div 4}</td> |
---|
68 | </tr> |
---|
69 | <tr> |
---|
70 | <td>\${3/0}</td> |
---|
71 | <td>${3/0}</td> |
---|
72 | </tr> |
---|
73 | <tr> |
---|
74 | <td>\${10%4}</td> |
---|
75 | <td>${10%4}</td> |
---|
76 | </tr> |
---|
77 | <tr> |
---|
78 | <td>\${10 mod 4}</td> |
---|
79 | <td>${10 mod 4}</td> |
---|
80 | </tr> |
---|
81 | <tr> |
---|
82 | <td>\${(1==2) ? 3 : 4}</td> |
---|
83 | <td>${(1==2) ? 3 : 4}</td> |
---|
84 | </tr> |
---|
85 | </table> |
---|
86 | </code> |
---|
87 | </blockquote> |
---|
88 | </body> |
---|
89 | </html> |
---|
90 | </pre></body></html> |
---|