You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by John Cartwright <jc...@ngdc.noaa.gov> on 2001/04/25 21:25:06 UTC

ClassCastException when passing a list of Beans to JSP page

Hello All,

I am hoping someone can solve this mystery for me since I'm stumped.  

I have a servlet which populates a vector with beans.  It then puts the
vector into the request object and forwards to a JSP page.

The JSP page pulls the vector out of the request and proceeds to call
methods on each bean in the list.

Sometimes the whole thing quits working and complains with a 

Internal Servlet Error:
javax.servlet.ServletException: sde.LayerBean
...
Root cause: 
java.lang.ClassCastException: sde.LayerBean
...

Restarting tomcat solves the problem, but I'd like to understand what's
going on. I'm assuming that it's the JSP page throwing the exception
(the errorPage directive engages).

Can someone enlighten me?  I'm using Tomcat 3.2.1 (standalone) on Linux
JDK1.3.  The JSP page is listed below.

Thanks!

 
-- john


<%@ page import="sde.LayerBean,java.util.*" %>
<html>
<body>
<%
   Vector v = (Vector)request.getAttribute("list");
   LayerBean layer;
   Iterator i = v.iterator();
   while (i.hasNext()) {
      layer = (LayerBean)i.next();
%>
<%=layer.getTableName()%><BR>
<% } %>
</body>
</html>





===============================================================================
John Cartwright
Professional Research Assistant / Associate Scientist
CIRES, SEG/NGDC/NOAA
(303) 497-6284
jcartwright@ngdc.noaa.gov
===============================================================================