This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Doubt in requestScope Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Doubt in requestScope" Watch "Doubt in requestScope" New topic
Author

Doubt in requestScope

raja ram
Ranch Hand

Joined: Mar 02, 2008
Posts: 169
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

Joined: Nov 24, 2005
Posts: 14687
    
  16

Did you post the same code twice ? I can't see any difference.


[My Blog]
All roads lead to JavaRanch
raja ram
Ranch Hand

Joined: Mar 02, 2008
Posts: 169
Hi,

I have edited the post.

Thanks
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

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

Joined: Aug 05, 2006
Posts: 637
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


SCJP, SCWCD, SCBCD
raja ram
Ranch Hand

Joined: Mar 02, 2008
Posts: 169
Hi,

Thanks for clearing my doubt.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Doubt in requestScope