Don't you mean to say that the two JSP pages are generating two separate classes
that are each declaring their own Website *inner* class? Your suggested solution
is, of course, correct - use a top-level class.
tim.

> Conrad Chan <[EMAIL PROTECTED]>
> It is not going to work.  Both ess.jsp and ess2.jsp are declaring their own
> Website subclass and they can't be cast to each other (They are totally
> different classes).  Use a real java class instead.
>  
> Conrad
> 
> -----Original Message-----
> From: Christian Meunier [mailto:[EMAIL PROTECTED]]
> Sent: Friday, March 16, 2001 5:02 PM
> To: Orion-Interest
> Subject: Class cast exception....
> 
> 
> Hi all, i got a class cast exception trying to use an instance of an object
> throught 2 jsp pages or so.
> dumb example:
>  
> fct.jsp:
> -----------------------
> <%!
> public class Website
>  {
>   private int num;
>   private String nom;
>  
>   public Website()
>   {
>    this.num=100;
>    this.nom="example";
>   }
>  }
> %>
>  
> ess.jsp:
> ------------------------
> <%@ include file="/fct.jsp" %>
> <%@ page import="java.util.*"%>
> <%
> Website ess=new Website();
> Vector v=new Vector();
> v.add(ess);
> session.setAttribute("essai",v);
> System.out.println(ess.getClass().getName());
> %>
>  
> ess2.jsp
> ---------------------------
> <%@ include file="/fct.jsp" %>
> <%@ page import="java.util.*"%>
> <%
> Vector v=(Vector)session.getAttribute("essai");
> Website ess=(Website)v.get(0);
> %>
>  
> => i first load ess.jsp and got the following in log:
> __jspPage2_ess_jsp$Website
>  
> =>When i load ess2.jsp i got a class cast exception and when i check the
> class name :
> __jspPage2_ess_jsp$Website
>  
> How i can bypass this trouble and why the class name is not Website and
> thats all ?
> Thx in advance for ur help.
>  
> Chris
> 


Reply via email to