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

You can choose to ignore EL

Yes, EL is a good thing that’s going to save the world as we know it. But sometimes you might want to disable it. Why?

Think back to when the assert keyword was added to the Java language with version 1.4. Suddenly the formerly unreserved and perfectly legal identifier “assert” meant something to the compiler. So if you had, say, a variable named assert, you were screwed. Except that J2SE version 1.4 came with assertions disabled by default. If you knew you were writing (or recompiling) code that didn’t use assert as an identifier, then you could choose to enable assertions.

So it’s kind of the same thing with disabling EL—if you happened to have template text (plain old HTML or text) in your JSP that included something that looked like EL (${something}), you’d be in Big Trouble if you couldn’t tell the Container to just ignore anything that appears to be EL and instead treat it like any other unprocessed text. Except there’s one big difference between EL and assertions:

El is enabled by default!

If you want EL-looking things in your JSP to be ignored, you have to say so explicitly, either through a page directive or a DD element.

Putting <el-ignored> in the DD

<web-app ...>
 ...
  <jsp-config>
     <jsp-property-group>
     <url-pattern>*.jsp</url-pattern>
     <el-ignored>
       true
     </el-ignored>
   </jsp-property-group>
</jsp-config>
...
</web-app>

Note

The page directive takes priority over the DD setting!

If there’s a conflict between the <el-ignored> setting in the DD and the isELIgnored ...

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