El Relational,Logical,conditional operators


Relational Operators
Introduction:

Equality or relational operator in JSP Expression Language is used to check the values returned by two expressions or operands. Comparisons can also be done with other values like boolean, string, integer, or floating point literals.

1.    Equal                          ( ==  or  eq)
2.    Not Equal                   (!=   or   ne)
3.    Less than                    (<     or   lt)
4.    Less than or equal      (<=   or  le)
5.     Greater than                (>     or  gt)
6.    Greater than or equal  (>=  or  ge)

Examples:

S.No
Logic
Expression
     Result
Symbol
1
Equal                         
${10.0==10}   or    ${10.0 eq 10}
true
== or eq
2
Not Equal                   
${10.0 != 10}   or    ${10.0 ne 10}
true
!=  or ne
3
Less than
${2<3}             or     ${4 lt 6}
true
<  or lt
4
Less than or equal     
${2 <= 4}          or    ${2 le 4}
true
>=  or le 
5
Greater than               
${3.2 > 2}         or    ${3.2 gt 2}
true
> or gt
6
Greater than or equal 
${3.2 > -2}         or   ${3.2 ge  2}
true
>= or ge

Logical Operators

S.No
Logic
Symbol
Expression
Result
1
And
and or &&
${true and false}or ${true && false} 
flase
2
Or
or   or ||
${true or false}  or $ {true || false} 
True
3
Not
not or !
 ${not false}       or ${! false}
True

Conditional Operator

Ex:

1.    ${  (3<4) ? “yes” : “no” }                          Output: yes
2.     ${ (true = = false) ? “Right” : “wrong”}   Output:  wrong

empty Operator :

$ {empty object}

·        if object does not exists
·        object is an empty array
·        object is an empty string
·        object is an empty collection.

In all other cases it returns false

$ {empty abcd}     true
$ {empty “abcd”}   false
$ {empty null}        true

EL Operator Precedence

1.    1.     Unary Operator:-    !, empty
2.    Arithmetic Operators:-
3.    *, /, %, +, -.
4.    Relational Operators
5.    Logical Operators
6.    Conditional Operators

EL Reserved Words

tue, false, null, empty, instanceOf, it, lt, ge, le, ne, eq,and,or,not,mod,div.

EL Vs Number

EL behaves very nicely with null.
·        In arithmetic operators it is treated as zero.
·        In string evaluation it is treated as empty string.
·        In Boolean operators it is treated as false.


Thanks For Making This Possible! Kindly Bookmark and Share it.

Technorati Digg This Stumble Stumble Facebook Twitter

No comments:

Post a Comment