• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Doubt in EL

 
Ranch Hand
Posts: 437
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Padma priya Gururajan
Ranch Hand
Posts: 437
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am unable to understand why option 'F' is chosen as the correct answer?
With regards,
Padma priya N.G.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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)
 
Padma priya Gururajan
Ranch Hand
Posts: 437
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Thanks.
With regards,
Padma priya N.G.
 
reply
    Bookmark Topic Watch Topic
  • New Topic