aspose file tools*
The moose likes JSP and the fly likes Struts ActionClass problem: can not cast?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Struts ActionClass problem: can not cast??" Watch "Struts ActionClass problem: can not cast??" New topic
Author

Struts ActionClass problem: can not cast??

Sanjay Deshpande
Ranch Hand

Joined: May 22, 2001
Posts: 111
I have a ActionForm class for a bean of struts framework.
it gives following error on compilation:
Cannot cast from Class to SubmitForm at line # 6:
1.public ActionForward perform(
2.ActionForm form,
3. HttpServletRequest request,
4. HttpServletResponse response) {
5.
6.SubmitForm f = (SubmitForm) form.; // get the form bean
7.// and take the last name value
8. String lastName = f.getLastName();
9.// Translate the name to upper case
10./and save it in the request object
11.request.setAttribute("lastName", lastName.toUpperCase());

// Forward control to the specified success target
12return (mapping.findForward("success"));
}
Darryl A. J. Staflund
Ranch Hand

Joined: Oct 06, 2002
Posts: 303
Hi there,
I am guessing you can't perform the cast because the "name" attribute of the associated action mapping isn't set or refers to a form of another type.
Darryl
Michal Bienek
Greenhorn

Joined: Jun 17, 2002
Posts: 29
Is there an extra "." after the word "form" on your casting line? Cause that's what would mess you up on compile time.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Struts ActionClass problem: can not cast??