Forums Register Login

Doubt in EL

+Pie Number of slices to send: Send
Hi,
10. public class MyBean {
11. private java.util.Map params;
12. private java.util.List objets;
13. private String name;
14. public java.util.Map getParams() { return params;}
15. public String getName() { return name; }
16. public java.util.List getObjects() { return objects; }
17. }


Which will cause errors(assume that an attribute name mybean can be found, and if of type MyBean)? (Choose all that apply)
A. ${mybean.name}
B. ${mybean["name"]}
C. ${mybean.objects.a}
D. ${mybean["params"].a
E. ${mybean.params["a"]}
F. ${mybean["objects"].a}

The answers are C and F.
Can you tell how they have arrived at this answer?
With regards,
Padma priya N.G.
+Pie Number of slices to send: Send
You're asking a lot about fundamental EL since yesterday. Please read your book, and refer to the specification to understand how the "." and "[]" work. Then ask what you do not understand.
Please understand that your questions are difficult to answer, because they deal with fundamental things which take time to explain. You don't seem to have read anything about EL before asking.
JSP.2.3.4 Operators "[]" and "." from the specification will answer most of your questions.
+Pie Number of slices to send: Send
Hi,
I am unable to understand why option 'F' is chosen as the correct answer?
With regards,
Padma priya N.G.
+Pie Number of slices to send: Send
Remember that a.b is the same as a["b"] ? C and F are the same. So if you understand C, you'll understand F You can only access a list via an index (integer), and "a" is not an index. When accessing a list, the container will try to call a.get(b), so b must be an integer.

(by the way, line 12 has a typo)
+Pie Number of slices to send: Send
Hi,
Thanks.
With regards,
Padma priya N.G.
Oh. Hi guys! Look at this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 809 times.
Similar Threads
HFSJ - Q15 on page 431
chapter:8,self test-15
EL Question from HFSJ
right to the dot operator should be a bean property?
HFS question 15 page # 423
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 18:25:28.