posted 11 years ago
Hi Bear,
Thanks very much for the advise. Yes, I am studying for the exam, and I am just right at EL chapter of HFSJ and see how simple EL is.
As for the question above, the original question (HFSJ p420) is :
<jsp:useBean id="person" type="foo.Employee" scope="request">
<jsp:setProperty name="person" property="name" value="Fred" />
</jsp:useBean>
Name is: <jsp:getProperty name="person" property="name" />
What happens if the servlet code looks like:
foo.Person p = new foo.Employee();
p.setName("Evan");
request.setAttribute("person",p);
The book answer is:
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 changed "person" to "employee", which is an existing bean attribute. Even if only type(employee) is specified without class, but the Container would find the "employee" class at the request. So I'd think it'd work. Not 100% sure though.
"There are no dumb questions" quoted from HFSJ. "To err is human; to forgive is divine"
OCPJP 6, OCEJWCD 6