Reference: Chapter -8 Page 420 of new book and 416 of old book
I have following two classes
abstract class person with attribute name.
class Employee which extends Person with attribute empId.
I have following code in my servlet
Person p = new Employee();
In my jsp I have:
<jsp:useBean id="personBean" type="com.example.Employee" scope="request">
<jsp:setProperty name="personBean" property="name"/>
Name is:: <jsp:getProperty name="personBean" property="name" />
If I run it, it works fine and displays Evan (which is expected according to me)
But the book at page 420 says, that it should fail at request time! The "personBean" attribute is stored at request scpde, so the <jsp:useBean> tag wont 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 dont understand why should it fail???
Am I doing anything different as it is not failing in my case??
One Point I noted is, In old book they have not specified any scope so it will by default search person in page scope so it should fail which is right,
but in new book they have specified scope="request" on <jsp:useBean> tag, so according to me it should not fail in this case.