when I write a <jsp:useBean>, the class attribute determines
the class of the new object (if one is created). it also determines
the type of the reference variable used in the generated servlet.
In JSP:
<jsp:useBean id="person" class="foo.Person" scope="page" />
Generated servlet:
food.person = null;
if(person==null) person = new foo.Person();
Is there a way to change the reference type from the actual
object type? In other words, make the reference type to be Person, and the object type to be say, Student.
No, it’s not possible.
But in a properly designed application, the controller (a servlet, or an action of your preferred MVC framework) creates the bean, and the view uses it.
And
<jsp:useBean>is obsolete for years. Use the JSP EL.Controller:
View: