Describing JSP Expression Language:
The JSP expression language allows a page author to access a bean using simple syntax such as $(name). Before JSP 2.0, we could only use a scriptlet, JSP expression, or a custom tag to include server state in the jsp page output. Expression Language (EL) was first introduced in JSTL 1.0. EL makes it easier to integrate server side state with the presentation output. Now it has its own independent specification document, which states that EL is generally applicable to a variety of technologies and is not dependent on the JSP specification. It is a simple language for accessing data, it makes it possible to easily access application data stored in JavaBeans components
Types of EL Expressions:
- Immediate and deferred expression
- Value expression
- Method Expression
Immediate and Deferred Expressions: There are two construct to represent the EL expressions: ${expr} and #{expr}. In a JSP page, ${exp} is used for expression that need to be evaluated immediately and #{expr} is used for expression that are used at a later time. Therefore, an EL tag used ${expr} syntax is called immediate expression and the EL expression using the #{exp} is called deferred expression.
Example: <fmt:formNumber values="${sessionScope.cart.sum}"/>
<h: inputText id="name" value="#{emp.name}"/>
Value Expression: Value Expression are used to refer to objects such as JavaBeans, collections, enumerations, and implicit objects, and their properties. Reference to an object is made using the value expression containing the name of the object.
Example: <prefix: tag>
some text ${expr}
</prefix>
Method Expressions: Method expression are used to call public methods, which return a value or object. It is usually a deferred expressions. JSF html tags represent UI components on a JSF page. These tags use method expressions to call functions that perform operations such as validating a UI component are handling the events generated on a UI component.
Example: <h:form>
<h:inputText id="email " value="#{emp.email}"
validator="#{emp.validateEmail}"/>
<h:commandButton id="submit" action="#{customer.submit}"/>
</h:form>
EL Operators: These are introduced in unified EL API so that developers
can perform arithmetic calculations. Now we can create EL expressions performing operations by using operators of EL.



Join the conversation! Your thoughts help the community grow.