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 page directive attribute, the directive always wins! That lets you specify the default behavior in the DD, but override it for a specific page using a page directive.

Using the isELIgnored page directive attribute

<%@ page isELIgnored="true" %>

Note

The page directive attribute starts with “is”, but the DD tag doesn’t!

Note

Watch out for the naming inconsistency!

The DD tag is <el-ignored>, so one might reasonably think that the page directive attribute would be, oh, maybe elIgnored? But no, one would be wrong if one jumped to the natural conclusion. The DD and directive for ignoring EL do not match! Don’t be fooled by <is-el-ignored> .

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset