Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Tudor Raneti
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
  • 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.
 
Ankit Garg
Sheriff
Posts: 9529
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic