Assume I have the following JSP code
-------------------
<jsp:useBean id="person" type="Person" class="Employee">
<jsp:setProperty name="person" property="*" />
</jsp:useBean>
-------------------
that is called from this HTML page
-------------------
<html><body>
<form action="TestBean.jsp">
name: <input type="text" name="name">
ID#: <input type="text" name="empID">
<input type="submit">
</body></html>
-------------------
where Person is an abstract class (with private name property and standard getName, setName methods) and Employee is a concrete subclass of Person(with private empID property and standard getEmpID, setEmpID methods).
When the Container builds the resulting servlet for this JSP, then a bean called "person" is either selected or created (if doesn't exist in page context) that has an object type of Employee that has a reference type Person.
Person person = new Employee();
Now polymorphically speacking, "person" should not be able to call the setter method in Employee (can only call methods in Person), but yet, the container can set both properties. Doesn't this violate the polymorphism rule in plain java?
-------------------
<jsp:useBean id="person" type="Person" class="Employee">
<jsp:setProperty name="person" property="*" />
</jsp:useBean>
-------------------
that is called from this HTML page
-------------------
<html><body>
<form action="TestBean.jsp">
name: <input type="text" name="name">
ID#: <input type="text" name="empID">
<input type="submit">
</body></html>
-------------------
where Person is an abstract class (with private name property and standard getName, setName methods) and Employee is a concrete subclass of Person(with private empID property and standard getEmpID, setEmpID methods).
When the Container builds the resulting servlet for this JSP, then a bean called "person" is either selected or created (if doesn't exist in page context) that has an object type of Employee that has a reference type Person.
Person person = new Employee();
Now polymorphically speacking, "person" should not be able to call the setter method in Employee (can only call methods in Person), but yet, the container can set both properties. Doesn't this violate the polymorphism rule in plain java?