tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kris Schneider" <k...@directthought.com>
Subject Re: ClassCastException when changing from HashMap to TreeMap
Date Fri, 17 Oct 2008 15:25:55 GMT
It looks like it might be a difference in the way HashMap.containsKey
and TreeMap.containsKey are implemented. If you look at the API docs,
TreeMap will throw ClassCastException but HashMap will not. When you
were using HashMap, did you actually get values returned or null?

On Fri, Oct 17, 2008 at 10:48 AM, Gabriel Belingueres
<belingueres@yahoo.com.ar> wrote:
>
> Hi,
>
> I was accessing a Map<Integer, MyClass> implemented with a HashMap<Integer,
> MyClass> from JSTL (v.1.1.2) using the following expression:
>
> ${map[param.myid].name} and it worked well.
>
> However, when I changed the implementation to a TreeMap<Integer, MyClass>
> the expression stop working because it throws ClassCastException saying that
> can't compare Strings with Integers.
>
> I know that ${param.myid} should resolve to a String, but I wanted to
> clarify if this is a normal behaviour or it is a bug, since it seems to be
> converting to Integer for HashMap but not for TreeMap.
>
> Best regards,
> Gabriel
>
> --
> View this message in context: http://www.nabble.com/ClassCastException-when-changing-from-HashMap-to-TreeMap-tp20034818p20034818.html
> Sent from the Taglibs - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
>
>



-- 
Kris Schneider <mailto:kris@directThought.com>
directThought  <http://www.directThought.com/>

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Mime
View raw message