| Author |
jsp:useBean tag query.
|
Vinayak Jallapelli
Greenhorn
Joined: Feb 27, 2008
Posts: 11
|
|
Hi All,
While reading Head First Servlets and JSP book (2nd Edition), I came across topic (on page 362, chapter 8) explaining how we can set the values from HTML form directly to Java Beans using "jsp:useBean" tag.
In the example, following classes are used:
The sample HTML form is as below. This form contains parameters whose name are equivalent to properties of above Java classes.
As per the book, we can use the following tag to set the form values straight to the bean:
My question is, in the above useBean tag, how does the container sets the EmpID attribute of the bean, since the instance that container creates is of type "foo.Person"? "foo.Person" has no visibility of empID property of its child class "foo.Employee".
Regards,
Vinayak
|
Best Regards,<br />Vinayak Jallapelli
|
 |
Seetharaman Venkatasamy
Ranch Hand
Joined: Jan 28, 2008
Posts: 5575
|
|
Vinayak Jallapelli wrote:
will it compile? probably typing error
Vinayak Jallapelli wrote:
My question is, in the above useBean tag, how does the container sets the EmpID attribute of the bean, since the instance that container creates is of type "foo.Person"? "foo.Person" has no visibility of empID property of its child class "foo.Employee".
here, first container create an instance of foo.Employee and then sets its value , then this object is assigned to the reference to foo.Person[which is a super class of foo.Employee]
<edit>
and while displaying empId , container will type cast to subclass then invoke the attribute like
</edit>
|
 |
 |
|
|
subject: jsp:useBean tag query.
|
|
|