where foo.Person is abstract and foo.Employee is an extension of Person.
The explanation at the end of the chapter seems to indicate the problem is only with the scope of the "person" attribute. The servlet is apparently storing it at the request scope. The standard action has a page scope by default. I thought that even if the jsp had scope="request" that it would fail since the real problem is that there is no object of type foo.employee out there. There is a class, but not a type. The type that is known is foo.Person.
I thought that even if the jsp had scope="request" that it would fail since the real problem is that there is no object of type foo.employee out there. There is a class, but not a type. The type that is known is foo.Person.
The reference for the Employee class is super class Person which doesn't have a method to return empID. There is an object of type foo.employee referenced by foo.Person.
Joined: Feb 03, 2005
Thanks for the reply, Chandra. But I'm still confused here -- I understand that if you do an instanceof test on p for either the Person class or the Employee class it will be true, but I wasn't sure that was what they meant by the "type" parameter.
In any case, by reading the explanation in the book, it seemed not to relate to the "type" of the object but only to its scope. In other words, they seem to be saying the reason it failed was that the jsp reference was in page scope but the servlet was request scope.
Appreciate the input -- still working on understanding it. Thanks...
Joined: May 05, 2005
From the explaination on Pg 416 on the same question I understood that there should be a class for an instance of the object to be created. Without the class the body of <jsp:useBean> is not executed. That should be enough for the code to not compile.
Regarding your first question about multiple quotes: There is no parsing required while reading what is typed inside an expression. Whatever is typed between <%= %> is considered as a single expression and evaluated. The value returned by the getParameter goes to the value attribute. So there won't be any error.
Hope this helps.
Joined: Feb 03, 2005
Thanks, Neo. That's interesting -- I've had so much trouble in the past with nested quotes in so many situations that it just looked wrong! It's nice that we don't hage to worry about that.