${emp.midName} 'midName' property here, 'emp' is exist but it does not contain .
Statement C meant that 'midName' property does not exist.
Goldern Rule of EL is that - It handles unknown or null values so that the page still displayseven if it can't find a property/attribute/key with the name in the expression.
There will not be any exception even if emp is null or does not exist. you will just see blank output
If you refer Kathy's book second edition page no.370 you will find there is a statement in bold which says "If the object is a bean but the named property doesn't exist, then an excpetion is thrown". Then I guess 'C' should be one of the answers.Please let me know if I am wrong.
I am refering HFSJ 1st Edition that says C is correct answer(Pg 432) but Erata of the book "http://oreilly.com/catalog/headservletsjsp/errata/headservletsjsp.confirmed"
says this: -
[432] Question 17, Option C; option C is invalid and should not be checked.
Can someone please clarify rules related to null key/property in an EL expression.
My understanding is as i said earlier as well -
EL handles unknown or null values gracefully - no exception
Eg- ${foo} - If foo attribute does not exist in any scopes then print nothing ${foo.bar} - If foo Bean/Map exist but if bar does not exist as property than also print nothing