This week's book giveaway is in the Testing forum.
We're giving away four copies of Data Structures the Fun Way: An Amusing Adventure with Coffee-Filled Examples and have Jeremy Kubica on-line!
See this thread for details.
  • 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
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Doubt in requestScope

 
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have the following code

This works fine also this.
<p>name--------->${name}</p>
but this doesnt work.


I know that requestScope is a map containing all the request scoped attributes in it.
why does it fail when. I pass an attribute rather than a string.

Thanks
[ November 10, 2008: Message edited by: raja ram ]
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you post the same code twice ? I can't see any difference.
 
raja ram
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have edited the post.

Thanks
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by raja ram:


I know that requestScope is a map containing all the request scoped attributes in it.



you know , it is a map right? then how come it(below one ) will work?


this will work



Hope this helps
 
Ranch Hand
Posts: 637
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Code #1 uses requestScope["name"] to access the request attribute name. This will work as expected.
However requestScope[name] , Here name is without quotes so the

1) container will now search for a attribute "name" in all the 4 scopes one after other and it will find name in request scope with a value "To test thekey and attribute differences"

2) Container will now convert this to
requestScope["To test thekey and attribute differences"] and it will search again a attribute with name = "To test thekey and attribute differences" in all the 4 scopes and it will find none and since EL handles null gracefully it will return empty string.

To confirm the above explanation try this EL empty operator.


Result:
requestScope["name"]--------->To test thekey and attribute differences
requestScope[name]--------->true

Hope its clear
 
raja ram
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Thanks for clearing my doubt.
 
please buy my thing and then I'll have more money:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic