wood burning stoves 2.0*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes question on EL 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 "question on EL" Watch "question on EL" New topic
Author

question on EL

Heilien Tsui
Greenhorn

Joined: Dec 08, 2008
Posts: 20
I am having problem on this question. partly because, i do not understand the question.

What is the question trying to describe ?





[Thumbnail for question.jpg]



SCJP 5, SCJD 5, SCWCD 5, SCDJWS 1.4, SCBCD 5, SCEA 5
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9293
    
  17

I think the question is fairly simple (wow I am weak at EL and still I got it ). The question is saying that there is instance of a class named Appliance in the application scope with the name - appl. Now that class has a map of properties. Now the question is not clear on the point that the name of the map is properties. So the Appliance class would look like this



So now when we write the EL

${appl.properties.name}

here appl refers to the instance of Appliance class, properties will get the properties map, in the map the question says that there is a key named "name" which has the value Cobia which is what we want to display.

In the second example, we use a request scoped attribute prop to get the name property. You must know that there are two ways of accessing a property of a map. So if we want, we could have written the above EL as

${appl.properties['name']}


Now here we have used a string name to refer to the key in the properties map. But if you remove the quotes, then the value in the square brackets will get evaluated. And we know that there is a request attribute named prop containing the value name. So we write this EL

${appl.properties[prop]}

So this EL will be first evaluated to

${appl.properties['name'}

and then the final value will get displayed...

[Edit: spelling correction]


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Heilien Tsui
Greenhorn

Joined: Dec 08, 2008
Posts: 20
Thanks Ankit, a very detail explanation
 
Consider Paul's rocket mass heater.
 
subject: question on EL