EL: the answer to, well, everything.

Or almost everything. But certainly an answer to two big complaints about putting actual Java into a JSP:

  1. Web page designers shouldn’t have to know Java.

  2. Java code in a JSP is hard to change and maintain.

EL stands for “Expression Language”, and it became officially part of the spec beginning with JSP 2.0 spec. EL is nearly always a much simpler way to do some of the things you’d normally do with scriptlets and expressions.

Of course right now you’re thinking, “But if I want my JSP to use custom methods, how can I declare and write those methods if I can’t use Java?”

Ahhhh... writing the actual functionality (method code) is not the purpose of EL. The purpose of EL is to offer a simpler way to invoke Java code—but the code itself belongs somewhere else. That means in a regular old Java class that’s either a JavaBean, a class with static methods, or something called a Tag Handler. In other words, you don’t write method code into your JSP when you’re following today’s Best Practices. You write the Java method somewhere else, and call it using EL.

Get Head First Servlets and JSP, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.