Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Working of Expression language

 
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I am using Tomcat 5.5 and Servlet 2.4 specification. I am learning J2EE basics from a book, "Pro JSP" from Apress edition. In this book, an example is given, which i am wondering ....how it works ?

The example is as follows: -

The authors want to say that, if in an EL expression you want to include "$" and "{" symbol....you need to escape it, and the example they gave is :-

In order to print = ${2 + 3} on the page...
the EL must be = ${'${'}2 + 3}

I am not able to understand how does the EL suggested in the book works ...it does display the output as desired....but how ? ... Because, before reading the EL mentioned by the authors, i was thinking, how i would have written an EL to print "${2 + 3}" on page!

I came up with following EL expressions which also give the same desired result: -

EL expression no. 1)

... here i have escaped the characters in the order they will appear from Left to Right in the String literal

EL expression no. 2)
[CODE}
${"${2 + 3}"}
[/CODE]
... here in this EL, i thought since, i just want to PRINT text ....that is string literal on the page,...why not put all the characters in double quotes ?

....so all the three expression works....but how do they work ?...what is the exact processing done behind the scenes ? Which one is more correct and appropriate ?
    Bookmark Topic Watch Topic
  • New Topic