File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes java.lang.ClassCastException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "java.lang.ClassCastException" Watch "java.lang.ClassCastException" New topic


Harish Maridi
Ranch Hand

Joined: May 20, 2008
Posts: 60
I have a struts form, I assaigned styleId to it.
and I wrote a java script as follows.

function redirectPageTo(tiknum) {
var name = document.getElementById('ApproveForm');
name.tiknum.value = tiknum;
It is sumitting the form. But I am getting java.lang.ClassCastException.
java.lang.ClassCastException: com.att.struts.Approvelist.ApprovelistForm

I am getting from the root cause that the exception is from the action class. But why it is coming and Suggest me any solution for that.

Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
This problem is caused by the fact that the ActionForm you're actually receiving as a parameter to the execute method in your Action class is different than the one you are expecting. Look closely at the action mapping you defined for this action in the struts-config.xml file and make sure that the ActionForm class you defined for it matches the one you coded in the Action class.

Consultant, Sima Solutions
Harish Maridi
Ranch Hand

Joined: May 20, 2008
Posts: 60
Thankyou very much Merrill...

Awesome java ranch....
I agree. Here's the link:
subject: java.lang.ClassCastException
It's not a secret anymore!