File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "question on EL" Watch "question on EL" New topic

question on EL

Heilien Tsui

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]

Ankit Garg

Joined: Aug 03, 2008
Posts: 9462

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


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


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


So this EL will be first evaluated to


and then the final value will get displayed...

[Edit: spelling correction]

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

Joined: Dec 08, 2008
Posts: 20
Thanks Ankit, a very detail explanation
I agree. Here's the link:
subject: question on EL
It's not a secret anymore!