Summary
A recent SDN article explains the difference between the #{...} and ${...} Unified Expression Language syntax, and gives the rational for having two different syntaxes.
Advertisement
In Introducing the EL #{…} Syntax, authors Pierre Delisle and Jennifer Ball explain that the ${...} syntax, which originated with JSP, provides immediate evaluation. By contrast, the #{...} syntax, which originated with JSF, provides deferred evaluation. The need for two different approaches arises because of the difference between JSPs fairly simply request processing and the more elaborate request/response life cycle of JSF components. You can get more information on the EL, and its design rationale, from JSF and JSP: What's New in Java EE 5, Frank Sommers' interview with Ed Burns, co-spec lead for JSF 1.2, and Jan Luehe, spec lead for JSP 2.1.
Java scriptlets mixed with HTML in JSPs have been considered to be quite unreadable by many. Both EL syntaxes attempt to minimize the need for such scriptlets. What is your opinion of the readability of code that uses EL?
it's fine provided you carefully section out the front-end code. just like functions in a traditional programming language are readable using the < 20 rule, i try to seperate out front-end code with constructs like jsp tags and jsp variables (c:set). when you can reduce the output/dynamic portion to simple things like iterating over an object and simply displaying it's properties, it's quite readable.