2

In the Java Unified Expression Language there are two base types of EL syntax:

${expression for immediate evaluation}
#{expression for deferred evaluation}

I understand the difference between these two in JaveServer Faces: JSF has a sense of a varying life cycle, and immediate expressions are always evaluated at page render while deferred expressions could be evaluated at page render, at postback, or both.

However, the difference is not clear to me for JavaServer Pages. JSP, from what I can tell, does not have the sense of life cycles that JSF has. In fact, I was somewhat surprised to learn that the deferred syntax was even legal in JSP. However, I now know that it is, because a backwards-compatibility <jsp-config> setting is available in the deployment descriptor to disable the detection of deferred syntax for pre-JUEL JSPs that use that syntax for some other purpose:

<deferred-syntax-allowed-as-literal>

So, the question is, what's the difference? Deferred syntax obviously can't mean exactly the same thing in JSP that it means in JSF, but I can't find any documentation anywhere that describes how to use deferred syntax for JSP.

Are they simply synonymous in JSP?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Nick Williams
  • 2,864
  • 5
  • 29
  • 43

1 Answers1

2

I found this from other forums, I hope it helps.

Check out the preface section of the JSP2.1 specification. Deferred expressions only really apply to custom tags where you have specified that the attribute is deferred. For the most part, I don't bother with them.

Basically If you use #{deferredSyntax} in template text, it triggers a translation error (they don't make sense outside of a tag attribute)

If you use #{deferredSyntax} in a tag attribute, it depends upon the tld declaration for what version of JSP that taglib supports. - JSP version supported < 2.1 == treat as literal - JSP version supported >= 2.1 : treat as deferred attribute - as long as it is marked as such.

You can set the page attribute:

<%@page deferredSyntaxAllowedAsLiteral="true"%> 
blitzen12
  • 1,350
  • 3
  • 24
  • 33
  • Thank you. That was indeed helpful. I had not before seen the `` and `` options for ``s within a `` declaration. However, the documentation is not super clear on this. Obviously it doesn't work the same way that it works in JSF (there are no postbacks in JSP). Does "deferred" here simply mean "whenever the developer who wrote the tag decides to evaluate it, or possibly never?" – Nick Williams Feb 11 '13 at 05:27
  • Also, could you post the links to the other forums that you gathered this from? Thanks. – Nick Williams Feb 11 '13 at 05:28
  • I got that info from here. http://www.coderanch.com/t/590264/JSP/java/JSP-Unified-EL – blitzen12 Feb 11 '13 at 06:28
  • you also need this: http://stackoverflow.com/questions/4812755/difference-between-jsp-el-jsf-el-and-unified-el and http://www.artima.com/lejava/articles/jsf_jspP.html – blitzen12 Feb 11 '13 at 06:37