el and jstl. jstl sources
TRANSCRIPT
![Page 1: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/1.jpg)
EL and JSTL
![Page 2: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/2.jpg)
JSTL Sources
• https://jstl.java.net/• http://www.oracle.com/technetwork/java/index-jsp-135995.html• http://www.tutorialspoint.com/jsp/jsp_standard_tag_library.htm• http://download.oracle.com/otndocs/jcp/jstl-1.1-mr2-spec-oth-JSpec
/
![Page 3: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/3.jpg)
Syntax notation
![Page 4: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/4.jpg)
Literal Expression
• To generate literal values that include the character sequence "${ " or “#{ “
• or
![Page 5: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/5.jpg)
• Literals for boolean, integer, floating point, string, and null in an eval expression.• Boolean - true and false• Integer - As defined by the IntegerLiteral • Floating point - As defined by the FloatingPointLiteral • String - With single and double quotes - " is escaped as \" , ' is escaped as \' ,
and \ is escaped as \\. • Null - null
![Page 6: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/6.jpg)
Errors, Warnings, Default Values
• EL does not provide warnings, just default values and errors.
![Page 7: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/7.jpg)
Arithmetic Operators
• Arithmetic is provided to act on integer (BigInteger and Long) and floating point (BigDecimal and Double) values. • Addition: +• Subtraction: -• Multiplication: *• Division: / and div• Remainder (modulo): % and mod
![Page 8: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/8.jpg)
Binary operators - A {+,-,*} B
• If A and B are null, return (Long)0• If A or B is a BigDecimal, coerce both to BigDecimal and then:
• If operator is +, return A.add(B)• If operator is -, return A.subtract(B)• If operator is *, return A.multiply(B)
• If A or B is a Float, Double, or String containing . , e, or E:• If A or B is BigInteger, coerce both A and B to BigDecimal and apply operator.• Otherwise, coerce both A and B to Double and apply operator
• If A or B is BigInteger, coerce both to BigInteger and then:• If operator is +, return A.add(B)• If operator is -, return A.subtract(B)• If operator is *, return A.multiply(B)
• Otherwise coerce both A and B to Long and apply operator• If operator results in exception, error
![Page 9: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/9.jpg)
Binary operator - A {/,div} B
• If A and B are null, return (Long)0• If A or B is a BigDecimal or a BigInteger, coerce both to BigDecimal
and return A.divide(B, BigDecimal.ROUND_HALF_UP)• Otherwise, coerce both A and B to Double and apply operator• If operator results in exception, error
![Page 10: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/10.jpg)
Binary operator - A {%,mod} B
• If A and B are null, return (Long)0• If A or B is a BigDecimal, Float, Double, or String containing . , e, or E,
coerce both A and B to Double and apply operator• If A or B is a BigInteger, coerce both to BigInteger and return
A.remainder(B) .• Otherwise coerce both A and B to Long and apply operator• If operator results in exception, error
![Page 11: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/11.jpg)
Unary minus operator - -A
• If A is null, return (Long)0• If A is a BigDecimal or BigInteger, return A.negate() .• If A is a String:• If A contains . , e, or E, coerce to a Double and apply operator• Otherwise, coerce to a Long and apply operator• If operator results in exception, error
• If A is Byte, Short, Integer, Long, Float, Double• Retain type, apply operator• If operator results in exception, error
• Otherwise, error
![Page 12: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/12.jpg)
Relational Operators
• The relational operators are:• == and eq• != and ne• < and lt• > and gt• <= and le• >= and ge
![Page 13: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/13.jpg)
A {<,>,<=,>=,lt,gt,le,ge} B
• If A==B, if operator is <=, le, >=, or ge return true.• If A is null or B is null, return false• If A or B is BigDecimal, coerce both A and B to BigDecimal and use the return value of A.compareTo(B) .• If A or B is Float or Double coerce both A and B to Double apply operator• If A or B is BigInteger, coerce both A and B to BigInteger and use the return value of A.compareTo(B) .• If A or B is Byte, Short, Character, Integer, or Long coerce both A and B to Long and apply operator• If A or B is String coerce both A and B to String, compare lexically• If A is Comparable, then:
• If A.compareTo(B) throws exception, error.• Otherwise use result of A.compareTo(B)
• If B is Comparable, then:• If B.compareTo(A) throws exception, error.• Otherwise use result of B.compareTo(A)
• Otherwise, error
![Page 14: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/14.jpg)
A {==,!=,eq,ne} B
• If A==B, apply operator• If A is null or B is null return false for == or eq, true for != or ne.• If A or B is BigDecimal, coerce both A and B to BigDecimal and then:
• If operator is == or eq, return A.equals(B)• If operator is != or ne, return !A.equals(B)
• If A or B is Float or Double coerce both A and B to Double, apply operator• If A or B is BigInteger, coerce both A and B to BigInteger and then:
• If operator is == or eq, return A.equals(B)• If operator is != or ne, return !A.equals(B)
• If A or B is Byte, Short, Character, Integer, or Long coerce both A and B to Long, apply operator• If A or B is Boolean coerce both A and B to Boolean, apply operator• If A or B is an enum, coerce both A and B to enum, apply operator• If A or B is String coerce both A and B to String, compare lexically• Otherwise if an error occurs while calling A.equals(B) , error• Otherwise, apply operator to result of A.equals(B)
![Page 15: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/15.jpg)
Logical Operators
• The logical operators are:• && and and• || and or• ! and not
![Page 16: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/16.jpg)
Binary operator - A {&&,||,and,or} B
• Coerce both A and B to Boolean, apply operator• The operator stops as soon as the expression can be determined, i.e., A and B
and C and D – if B is false, then only A and B is evaluated. • Unary not operator - {!,not} A
• Coerce A to Boolean, apply operator
![Page 17: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/17.jpg)
Empty Operator - empty A
• The empty operator is a prefix operator that can be used to determine if a value is null or empty.• To evaluate empty A• if A is null, return true• Otherwise, if A is the empty string, then return true• Otherwise, if A is an empty array, then return true• Otherwise, if A is an empty Map, return true• Otherwise, if A is an empty Collection, return true• Otherwise return false
![Page 18: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/18.jpg)
Conditional Operator - A ? B : C
• Evaluate B or C, depending on the result of the evaluation of A.• Coerce A to Boolean:
• If A is true, evaluate and return B• If A is false, evaluate and return C
![Page 19: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/19.jpg)
Parentheses
• Parentheses can be used to change precedence, as in: ${(a*(b+c))}
![Page 20: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/20.jpg)
Operator Precedence
• Highest to lowest, left-to-right.• [] .• ()• - (unary) not ! Empty• * / div % mod• + - (binary)• < > <= >= lt gt le ge• == != eq ne• && and• || or• ? :
• Qualified functions with a namespace prefix have precedence over the operators.Thus the expression ${c?b:f()} is illegal because b:f() is being parsed as aqualified function instead of part of a conditional expression. As usual, () can beused to make the precedence explicit, e.g ${c?b:(f())}
![Page 21: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/21.jpg)
Reserved Words
The following words are reserved for the language and must not be used as identifiers.
and eq gt true instanceof
or ne le false empty
not lt ge null div mod
• Note that many of these words are not in the language
![Page 22: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/22.jpg)
Functions
• The EL has qualified functions, reusing the notion of qualification from XMLnamespaces (and attributes), XSL functions, and JSP custom actions. • Functions are mapped to public static methods in Java classes.
The full syntax is that of qualified n-ary functions:
[ns:]f([a1[,a2[,...[,an]]]])
Where ns is the namespace prefix, f is the name of the function, and a is anargument.
![Page 23: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/23.jpg)
Getting Request Parameters
![Page 24: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/24.jpg)
Nested Properties
![Page 25: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/25.jpg)
Operators
![Page 26: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/26.jpg)
Automatic Type Conversion
![Page 27: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/27.jpg)
Default Values
![Page 28: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/28.jpg)
Required Prefixes
![Page 29: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/29.jpg)
Summary
![Page 30: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/30.jpg)
<c:out>
![Page 31: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/31.jpg)
<c:set>
![Page 32: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/32.jpg)
<c:remove>
![Page 33: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/33.jpg)
<c:catch>
![Page 34: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/34.jpg)
<c:if>
![Page 35: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/35.jpg)
<c:choose>
![Page 36: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/36.jpg)
<c:when>
![Page 37: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/37.jpg)
<c:otherwise>
• Represents the last alternative within a <c:choose> action
![Page 38: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/38.jpg)
<c:forEach>
![Page 39: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/39.jpg)
<c:forTokens>
![Page 40: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/40.jpg)
<c:import>
![Page 41: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/41.jpg)
<c:url>
![Page 42: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/42.jpg)
<c:redirect>
![Page 43: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/43.jpg)
<c:param>
![Page 44: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/44.jpg)
<fmt:seLocale>
![Page 45: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/45.jpg)
<fmt:timeZone>
![Page 46: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/46.jpg)
<fmt:setTimeZone>
![Page 47: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/47.jpg)
<fmt:formatNumber>
![Page 48: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/48.jpg)
![Page 49: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/49.jpg)
<fmt:parseNumber>
![Page 50: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/50.jpg)
<fmt:parseDate>
![Page 51: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/51.jpg)
![Page 52: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/52.jpg)
<sql:query>
![Page 53: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/53.jpg)
![Page 54: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/54.jpg)
<sql:update>
![Page 55: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/55.jpg)
![Page 56: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/56.jpg)
<sql:setDataSource>
![Page 57: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/57.jpg)
<sql:param>
• Subtag of <sql:query> and <sql:update>
![Page 58: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/58.jpg)
fn:contains
![Page 59: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/59.jpg)
fn:containsIgnoreCase
![Page 60: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/60.jpg)
fn:endsWith
![Page 61: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/61.jpg)
fn:escapeXml
![Page 62: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/62.jpg)
fn:indexOf
![Page 63: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/63.jpg)
fn:join
![Page 64: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/64.jpg)
fn:length
![Page 65: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/65.jpg)
fn:replace
![Page 66: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/66.jpg)
fn:split
![Page 67: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/67.jpg)
fn:startsWith
![Page 68: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/68.jpg)
fn:substring
![Page 69: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/69.jpg)
fn:substringAfter
![Page 70: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/70.jpg)
fn:substringBefore
![Page 71: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/71.jpg)
fn:toLowerCase
![Page 72: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/72.jpg)
fn:toUpperCase
![Page 73: EL and JSTL. JSTL Sources](https://reader035.vdocuments.site/reader035/viewer/2022062217/5697bfc11a28abf838ca45be/html5/thumbnails/73.jpg)
fn:trim