I want to be able to assign the class attribute of a
jsp:useBean tag dynamically at request-time. Depending on the
servlet path, I set a different bean in the request before forwarding to my JSP. One of these beans is a super-class of the other.
I thought that assigning the value of the super-class to the "type" attribute would take care of this problem, allowing me to reference either class using the useBean id. But when I do that, I get compiler errors because the methods defined in my sub-class aren't defined in my super-class.
Alternatively, I tried to define a request-time expression (" <%= myClass %> ") as the value of the useBean "class" attribute, but request-time expressions are not legal as useBean attributes.
Finally, I tried using a scriplet which defines an if-statement to conditionally declare the useBean tag with the appropriate class attribute. However, in this case I get an error stating that duplicate useBean tags are not permitted (even though the tags are declared under mutually exclusive conditions).
Can anyone suggest a proven method for associating a useBean tag with a super-class, then invoking sub-classes of the superclass using the tag?
thanks in advance for your help!
John