java.lang.ClassCastException

Respected Sir

I am getting the java.lang.ClassCastException in the following while comparing the value id.equals() in th follwoing if.

Please suggest some solution.

<%

if (session.getAttribute("stoneId") != null){

String id = (String) session.getAttribute("stoneId");

if (id.equals(request.getAttribute("stone"))) {

%>

<strong><c:out value="${stone.codeName} " /></strong>

<%

}

Thanx in advance

[497 byte] By [chahalkhushwindera] at [2007-11-27 8:15:33]
# 1

well the object you get for "stone" is not a String object. equals only works when the two objects are of the same type.

You can implement the toString() method on the stone object to turn it into a String and you can compare against that, or perhaps it has a stone.getId() that returns the value you want to compare to?

gimbal2a at 2007-7-12 20:00:21 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
thanx a lot gimbal:)
chahalkhushwindera at 2007-7-12 20:00:21 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...