I define a static inner class inside my JSP, I create an instance of it and then I keep the resulting object as a session attribute. When getting the attribute again I will get a ClassCastException when downcasting to my inner class. Is this a bug or standard behaviour?
Thanks, Ernesto GarcĂa <html> <%! private static class MyInnerClass { private int number; public MyInnerClass(int number) { this.number = number; } public void increment() { this.number++; } public String toString() { return Integer.toString(number); } } %> <% Object instanceObj = session.getAttribute("instance"); if (instanceObj == null) session.setAttribute("instance", new MyInnerClass(1000)); else { // Uncomment the following line to get ClassCastException: //MyInnerClass instance = (MyInnerClass)instanceObj; //instance.increment(); %> <p>instanceObj.getClass() = <%= instanceObj.getClass() %> <p>instanceObj = <%= instanceObj %> <% } %> </html> --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]