This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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 Android Security Essentials Live Lessons this week in the Android 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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts ActionClass problem: can not cast??
 
Similar Threads
Struts - Cannot compile class
Cannot retrieve mapping for action
No Getter method for LastName property of bean
Perform() not called in Action class - Struts on Weblogic 6.0
Frustration with struts. Please help!!!