Hello All,
To begin with, I have a simple inheritance hierarchy:
Class B and class C, both extend from class A
Next, I have the following two
JSP pages:
infobean1.jsp
<jsp:useBean id="info" class="com.abc.B" scope="session" />
<jsp:forward page="/infobean2.jsp" />
infobean2.jsp
<jsp:useBean id="info" class="com.abc.C" scope="session" />
I get a ClassCastException (reason being that B and C both are different types, although they have a common base class). But, my query is on how the <jsp:useBean> element behaves (pls. correct me wrong)
infobean1.jsp
<jsp:useBean id="info" class="com.abc.B" scope="session" />
The JSP engine tries to look for a bean type B in the session scope with id- info, it fails and instantiates a new object, and then we have a forward...
In infobean2.jsp page [same session]
<jsp:useBean id="info" class="com.abc.C" scope="session" />
The JSP engine tries to look for a bean type C in the session scope with id- info, it suceeds at compile time but fails at run-time nd hence we get the ugly strack trace, but my question is that why does it suceeds at the first place, cause B and C are both un-related classes, rather it should fails and instantiates a new object.....(and then ofcourse we should not get the exception trace)
Pls. help...