Vector confusion
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Archie_Marsden
Posted On:   Monday, January 7, 2002 09:34 AM

I have been using Vectors in JAVA classes and JSP pages with great success. However, I am currently working on a JSP that requires me to use two Vectors. I establish each Vector as follows: Vector v1 = new Vector(); Vector v2 = new Vector(); v1 = foo.getThingOne(); v2 = foo.getThingTwo(); The problem is that as soon as I try to access v2 I get a java.lang.ClassCastException on v1. Can anyone explain what I'm doing wrong? Thanks, Archie    More>>

I have been using Vectors in JAVA classes and JSP pages with great success. However, I am currently working on a JSP that requires me to use two Vectors. I establish each Vector as follows:


Vector v1 = new Vector();

Vector v2 = new Vector();



v1 = foo.getThingOne();

v2 = foo.getThingTwo();




The problem is that as soon as I try to access v2 I get a java.lang.ClassCastException on v1.

Can anyone explain what I'm doing wrong?


Thanks,


Archie

   <<Less

Re: Vector confusion

Posted By:   Christopher_Schultz  
Posted On:   Monday, January 7, 2002 10:00 AM

Are you storing these in the session?



I've had a problem in the past when using a relodable JSP, I was pulling an object out of the session and casting it appropriately.



When the re-load occurred, the session kept the "old" objects, and the ClassLoader loaded a new copy of my class. When I tried to cast the object from the session, the newly loaded class wasn't the same, and boom! ClassCastException.



Are you getting a CCE on the Vector, or on one of your own classes? I found that this didn't happen with standard Java classes, because they were loaded using the primordial ClassLoader and not the one for the JSPs.



-chris
About | Sitemap | Contact