0

Hi all,

I have two jsp pages say jsp1 and jsp2.

In jsp1 I have the following line:

<%@ page contentType="text/html;charset=UTF-8" language="Java" import="java.sql.*" %>
<jsp:useBean id="one" scope="session" class="mypackage.myclass1" />

In jsp2 I have the following line:

<%@ page contentType="text/html;charset=UTF-8" language="Java" import="java.sql.*" %>
<jsp:useBean id="two" scope="session" class="mypackage.myclass2" />

At runtime, if I open jsp1 it opens and loads all data appropriately, but if I try accessing jsp2 via a link or button, I get th following error on Tomcat's stacktrace:

org.apache.jasper.JasperException: java.lang.ClassCastException: mypackage.myclass1 cannot be cast to mypackage.myclass2

if I close the application and reopen it.If I access jsp2 and then try to access jsp1 I get the following similar message:

org.apache.jasper.JasperException: java.lang.ClassCastException: mypackage.myclass2 cannot be cast to mypackage.myclass1

Please assist and know that your help will be highly appreciated.
Thanks in advance!

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by dangari
0

That should only happen if you have used the same id in both cases.

OOh..so simple yet so true...thanks masijade...I don't know why I overlooked the id...Thanks again.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.