from the servlet code , it is a polymorphic reference
foo.Person p = new foo.Employee();
p.setName("Evan");
request.setAttribute("person", p);
so for the standard action , it will only work with this
<jsp:useBean id="person" type="foo.Person" class="foo.Employee" scope="request" />
The above will also work with following:
<jsp:useBean id="person" type="foo.Person" scope="request" />
AND
<jsp:useBean id="person" type="foo.Employee" scope="request" />
if only the
"type" attribute is mentioned then the attribute with the same id which in our case is "person" should exist in the "request" scope.
It seems the web container does a check of something like:
if ( person attribute exists in request scope
&& [object referred by attribute "person" stored in "request" scope] instanceof
[type= say "foo.Employee"]
)
THEN
return the reference to that object referred to by person attribute
ELSE
throw an exception