• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts ActionClass problem: can not cast??

 
Sanjay Deshpande
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 314
2
Android Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there an extra "." after the word "form" on your casting line? Cause that's what would mess you up on compile time.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic