aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes HFS question 15 page # 423 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "HFS question 15 page # 423" Watch "HFS question 15 page # 423" New topic
Author

HFS question 15 page # 423

Sandya Bhaskara
Ranch Hand

Joined: Aug 20, 2004
Posts: 73
in the MyBean class params,objects and name are not explicitly initialized..so they will be initialized to null..and the corresponding get methods return null...so how come there wont be errors for options A B D and E?? the answer says C and F will give errors because list objects will not hav properties...and what is that property "a"???it is no where in the program...quite confused


Sandy<br />SCJP1.4 SCWCD1.4<br />SCBCD(preparing)
Sandya Bhaskara
Ranch Hand

Joined: Aug 20, 2004
Posts: 73


which will cause errors -assume that an attribute named mybean can be found and is of type MyBean?

A.${mybean.name}
B.${mybean["name"]
C.${mybean.objects.a}
D.${mybean["params"].a}
E.${mybean.params["a"]
F.${mybean["objects"].a}
Sandya Bhaskara
Ranch Hand

Joined: Aug 20, 2004
Posts: 73
is that something to do with polymorphism?the question mybean is an attribute for object of type mybean=>mybean is an attribute of the object a class that extends mybean ??in that case understood the question..but am i right??
Jeff Huxley
Greenhorn

Joined: Sep 19, 2004
Posts: 3
I have the same question. I'm looking at question #15 on page 423 and don't get what "a" is. Is this a typo? If it�s not I�m missing something and would appreciate a little guidance. Thanks
Henrik Krievs
Ranch Hand

Joined: Jan 05, 2004
Posts: 59
Hi' !

I've tried to code the example - and I don't get any errors at all....

But, I think, according to HF - if and attribut is missing/lacking - EL would ignore that. So I think, in the example, the 'a' - is supposed to be an map-key....

Rgds, Henrik
Gabriel Forro
Ranch Hand

Joined: Apr 16, 2004
Posts: 59
Hi!

I try to explain it:
1. You have a bean 'MyBean', which has 3 properies: name, objects, params
2. You can access a bean and its properties through EL on a JSP page. So ${mybean.objects} returns a List object
4. You can access the items in List objects through EL as well, but You must use [] instead of . operator, so ${mybean.objects.a} is not correct
5. List interface has not got a getA() 'bean like' method, at the same time List is not a Map, so ${mybean.objects.a} is not valid EL expression.

Note:
If You try to acces a property, which is not defined for the bean, for example ${mybean.notAProperty}, You get a javax.servlet.jsp.el.ELException exception.


Gabriel
Henrik Krievs
Ranch Hand

Joined: Jan 05, 2004
Posts: 59
Hi Gabriel !

I don't get any exceptions [using Tomcat 5.xx.28] - even if I write
${myBeanThatDonotExist.attrib} ??

- Shouldn't it give some kind of error ?

Rgds, Henrik
Gabriel Forro
Ranch Hand

Joined: Apr 16, 2004
Posts: 59
Hello Henrik,

Yes You don't get, as the bean does not exist.
If you try:
${myBeanThatExists.attribThatDoesNotExists}

You get a nice exception
Let's say we have ${X.Y} EL expression
If the first section of the EL (e.g. ${X. ) evaluates an object and that object is not a Map and it does not have a getY() function, than an exception is throwed.
[ October 11, 2004: Message edited by: Gabriel Forro ]
sam siu
Greenhorn

Joined: Mar 03, 2005
Posts: 4
So, the bean is still legal even without setter methods? Or if the expression is not map, list or array, it will be treated as a bean automatically without checking whether it's a legal bean and getter method will be called. Anyone could me help me clarify this?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HFS question 15 page # 423