• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

${} vs %{} vs #{}?

 
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I remember reading that $ is immediate evaluation and % is lazy evaluation in EL but i might've been confused somehow, i can't find a link back to that.
Anyway they both work in EL. Then there's the #{} that is OGNL and throws this in EL:
org.apache.jasper.JasperException: /index.jsp(14,38) #{..} is not allowed in template text

P.S. ${} and %{} both work in JSP.
 
Sheriff
Posts: 9707
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

P.S. ${} and %{} both work in JSP


Are you sure?? ${} is EL %{} is not. %{} is part of the OGNL syntax which is used to get values from the default object of the ActionContext (the default is the ValueStack i.e. %{} by default gets values from the ValueStack). %{} can be used with # i.e. %{# } is used to get a value from the ActionContext itself. The ActionContext contains the attributes of different scopes so if you write %{#session['attr']} , the value of the session scoped attribute named attr is returned...
 
Tudor Raneti
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think i get the difference, i might've mistaken and tried %{} in a struts 2 enabled envirnoment. In a simple HelloWorld JSP app %{} doesn't work (not EL). Thanks.
 
reply
    Bookmark Topic Watch Topic
  • New Topic