Hi,
I ran into a ClassCastException problem when accessing a variable declared
as global in the main JSP page from an included JSP page. In my Main.jsp
page, I declared dp (DecisionPoint) as global variable. The value returned
from a javaBeans method call was saved in dp. Then the included jsp page
(details.jsp) accessed the Enumeration return from a method call of dp. The
class name of the enumeration 'element ' object did say it's DomainMember
class when I call getClass().toString(). Everything seemed to be fine at
this point. But when the element object is cast to DomainMember class, a
ClassCastException was thrown.
// in included JSP page
DomainMember dm = (DomainMember)(dms.nextElement());
Please note that DecisionPoint, WebProcessor and DomainMember classes are
not in the servlet classpath.
I suspect that this might be related to different class loaders problem. But
if it does, I'm not sure why since the included JSP along with the main.jsp
are compiled into one servlet class. Could someone please kindly explain
this to me?
If one needs to access a variable in a included JSP file, is there a way to
resolve this problem?
Can anyone please help?
The contents of Main.jsp and Details.jsp are listed below.
Your help is much appreciated.
V. Lee
----------------------------------------------------------------------------
-----------------------
-- Main.jsp
<%@ page import="weblogic.html.*, java.util.*, ...." %>
<%! DecisionPoint dp = null; %>
<%! Hashtable params = new Hashtable(); %>
<jsp:useBean id="web" class="com.aaa.WebProcessor" scope="request" />
...
<%
params.clear();
dp = web.getControlData("MySelection", "description");
if (dp == null)
{
out.println("<b>Error: Failed to get control data for objct
'MySelection'.</b>");
}
else
{
params.put("CAPTION", "Operating System");
params.put("CONTROL_ID", "MySelection");
params.put("NONE_TEXT", "None");
%>
<%@ include file="Details.jsp" %>
<% } %>
-- Details.jsp
<%
Enumeration dms = dp.getDomainMembers();
while (dms != null && dms.hasMoreElements())
{
Object ob = dms.nextElement();
out.println("ClassName=" + ob.getClass().toString());
DomainMember dm = (DomainMember)(dms.nextElement());
}
%>
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html