O'Reilly logo

Head First Servlets and JSP, 2nd Edition by Bert Bates, Bryan Basham, Kathy Sierra

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required