[size=12]I have 2 questions regarding EL and standard action from chapter 8 and 9 of HF
Servlets and
JSP.
QUESTION 1:
==========
In chapter 8 on page 399,it says :
"EL handles null values gracefully" and there is an example that says, "there is
an attribute named "bar" but does not have a property or key named "foo". "
so if there is an expression like
${bar[foo]} ,it will print null or nothing.I assume because foo is an unquoted
string so it will look for an attribute name foo to replace the property with foo's value.
But foo does not exists, so it will return null.
On page 457 last line of the bullet point says:
"Remember that the EL expression ${bean.notAProperty} will throw an exception."
My question is the difference of output of 2 scenerios above are because of
usage of operators (.) and [] ?
QUESTION 2:
===========
there is a question on page 358 in chapter 8 regarding <jsp:useBean> standard action
that what will be the output?
JSP code :
<jsp:useBean id="person" type="foo.Employee" request="scope">
jsp:setPropery name="person" property="name" value="Fred" />
</jsp:useBean>
Servlet code:
foo.Person p = new foo.Employee();
p.setName("Evan");
request.setAttribute("person",p);
Answere to this question on page 420 says:
FAILS at request time.The "person" attribute is stored at request scope,
so the <jsp:useBean> tag won't work since it specifies only a type.The
Container knows that if you have only a type specified,there must be an
existing bean attribute of that name and scope.
I am confused as it seems Servlet has done all the work i.e
created a bean and set it in attribute at request scope.All requirement
seems to be fullfilled then what is wrong here?
On page 356,last four line says:
if you use type without class,you better make certain that bean is already
stored as an attribute ,at the scope and with the id you put in the tag.
Thanks.