Expression Language
What is EL? The JSP Expression Language(EL) is simple, special purpose language designed for the web application environment. EL was originally developed in connection with JSP standard Tag Library but not it has been incorporated in JSP 2.0.
EL Syntax ${expression}
Whatever is inside the curly braces is evaluated at runtime and sent to the JSO output stream in place of ${}. You can use an expression as the entire value of an attribute.
Literals and Variables
boolean ${true} and ${false} integers ${68412} floating point numbers with a decimal point ${3.141} string enclosed either with quotation marks ${“hello”} The null value ${null}
Implicit objects
pageContext pageScope requestScope sessionScope applicationScope Param paramValues header headerValues cookie
Extracting property values ${beanName.propertyName} or ${beanName[“propertyName”]}
Arithmetic Operators
Addition ${a+b} Subtraction ${a-b} Multiplication ${a*b} Division ${a/b} Modulo ${a%b}
Relational Operators
>,<,>=,<=,!= Greater than gt Less than lt Equals eq Greater than or equals ge Less than or equals Not equals
Logical operators
&& (and) || (or) ! (not)
Empty
It will check whether object is empty or not
${empty obj}
Function implementation class
Like custom tags functions are implemented in java classes and registered in TLD. The implementation function must be public static method.
public class currency { public static double convert(double amount, String fromcurrency, String tocurrency) { return amount * 1.44; } }
Registering the function
In order to make the function available to a web application through EL, we need to register it in Tag Library Descriptor(TLD)
Element used to register functions