This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I was shocked to see that I got a ClassCastException Bean classes are well defined and are accessible without any problems. What I noticed is that pageContext.findAttribute() is being used in jsp:setProperty and thats why my string attribute named "abc" got a ClassCastException.
You declare 'abc' as a page-scoped variable of type String. Then you use a useBean action that specifies a different class. This is wrong. The useBean action will create a new variable only if a scoped variable with the specifid id does not already exist. When a scoped variable already exists, the useBean action binds to the existing variable.
And since the existing variable is of a different type than the action declares, you get a ClassCastException. Plain and simple.