I have not tried it yet. I have not set up my environments yet. In fact, I changed the original question in HFSJ page 420, trying to confirm that my change would work, as I think it would. Thanks for prompt reply.
P.S. I know that you are studying for the exam, but be aware that JSP actions such as getProperty and setProperty are obsolete, replaced by the JSTL and EL as of JSP2 in 2002, so they're not used in modern JSP code anymore (or at least shouldn't be).
Joined: Nov 14, 2012
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" />
Name is: <jsp:getProperty name="person" property="name" />
What happens if the servlet code looks like:
foo.Person p = new foo.Employee();
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.