0 Replies Latest reply on Nov 25, 2006 3:11 PM by Martin Rui

    exception thrown: passing an object from a bean to a JSP

    Martin Rui Newbie

      I have a class on /lib, here is:

      package auxiliar;

      public class Tabla {
      public String oid;
      public String ip;
      public int frecuencia;
      public int inicio;
      public int fin;

      public Tabla (String oid, String ip, int frecuencia, int inicio, int fin) {
      this.oid = oid;
      this.ip = ip;
      this.frecuencia = frecuencia;
      this.inicio = inicio;
      this.fin = fin;

      And then I have a bean like about this:

      public class VerOid {

      public ArrayList ver () {

      ArrayList salida = new Arraylist();
      while( rs.next() ) {
      salida.add(new Tabla(_oid, _ip, _frecuencia, _inicio, _fin));

      And at last, I have a JSP like this:

      <jsp:useBean id="id1" scope="session" class="bean.VerOid"/>


      ArrayList d = id1.ver();

      out.println( d.size());


      out.println( ( (Tabla) (d.get(0)) ).oid );

      ArrayList ff = new ArrayList();
      ff.add(new Tabla ("1.1.","127.",3,4,5));

      out.println( ( (Tabla) ff.get(0) ).frecuencia );


      d.size no problem
      With ff neither.

      But out.println( ( (Tabla) (d.get(0)) ).oid ); thrown an exception java.lang.ClassCastException and I don't know why.

      I have JDK 1.4.