Step 17- Expression Language

Expression Language-

It’s used to simplify the process of accessing data.
Syntax-  ${expression}

Here is an example of how to use the Expression Language (EL) in a JSP page:

<%@ page language="java" contentType="text/html; charset=UTF-8"
<!DOCTYPE html>
<title>EL Example</title>
        // Setting a variable in the page scope
        request.setAttribute("name", "John Smith");
    <h1>Hello, ${name}</h1>
    <p>Today's date is ${today}</p>

In this example, the JSP page sets a variable called “name” in the page scope using the request object, and then uses EL expressions to display the value of the “name” variable and the current date in the HTML. The result of this JSP page will be something like this:

Hello, John Smith
Today's date is Mon Jan 24 2022

You can also use EL for simple mathematical and logical operations, for example:

<p>The result of 2 + 2 is ${2+2}</p>

The result of this will be

The result of 2 + 2 is 4