Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt in requestScope

 
raja ram
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • 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 ]
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Hi,

I have edited the post.

Thanks
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • 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
 
Deepak Jain
Ranch Hand
Posts: 637
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Hi,

Thanks for clearing my doubt.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic