JSP Expression Language

tutorial and example
tutorial and example

JSP introduced the concept of expression language (EL) in JSP 2.0 version. The purpose of expression language is to access and manipulate data easily without using any type of scriptlet.

Why Expression language?

Before JSP 2.0, scriptlets are used to handle the business logic. But it is difficult task for web designers to understand and code the java part in scriptlets. Hence, now expression language is used to overcome this difficulty. 

Syntax

This is the simple syntax of expression language.

Expression Language Operator

JSP expression language provides an easy way to perform various arithmetic, relational, logical operations. These are some of the frequently used operators: –

  • Arithmetic operators – It contains various mathematical operators such as addition (+), subtraction (-), division (/ or div), module (% or mod), multiplication (*).
  • Logical operators – It contains operators like && (and), || (or).
  • Relational operators – It contains operators like < (less than), > (greater than), <= (less than or equal to), >= (greater than or equal to).

Example of JSP Expression Language Operator

This is a simple example of JSP operators that perform various mathematical operations between two numbers (10 & 5) directly.

Index.jsp

Output: