• 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

Question on EL: If it’s NOT a String literal, it’s evaluated

 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello All.
I have a question that is confusing me regarding EL. The following line is taken from HFSJ 2nd Edition


If there are no quotes inside the brackets, the Container evaluates what’s inside the brackets by searching for an attribute bound under that name, and substitutes the value of the attribute



Here is what I tried in a JSP



No output when using " [] " but got MyName printed when using "." .
Can anyone kindly explain why "name" inside [] cannot be resolved by the container since the attribute "name" is present in session scope ? Am I missing some point/information ?
I'm using tomcat 6.16.

Kind regards.
Hasnain Javed.
 
Ranch Hand
Posts: 453
Google Web Toolkit Hibernate Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


here in the first case that is without quotes, container starts looking for an attribute in all the scopes and gets the value MyName.
hence and there is no any attribute in the sessionScope named MyName hence nothing is printed.

in the second case container looks for the key named "name" in the map of session attributes. it finds one with the value MyName and is printed.

avi sinha
 
Hasnain Javed Khan
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

avi sinha wrote:
here in the first case that is without quotes, container starts looking for an attribute in all the scopes and gets the value MyName.
hence and there is no any attribute in the sessionScope named MyName hence nothing is printed.



It was so trivial (Thanks to HFSJ => There are no Dumb Questions). It implies I need to give my brain some rest
Thanks Avi .

Kind Regards.
Hasnain.
 
avi sinha
Ranch Hand
Posts: 453
Google Web Toolkit Hibernate Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Hasnain Javed Khan wrote:Thanks Avi .
Kind Regards.
Hasnain.



you're welcome

avi sinha
 
Note to self: don't get into a fist fight with a cactus. Command this tiny ad to do it:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic