File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes inconvertible types problem with struts tutorial Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "inconvertible types problem with struts tutorial" Watch "inconvertible types problem with struts tutorial" New topic
Author

inconvertible types problem with struts tutorial

Tony Evans
Ranch Hand

Joined: Jun 29, 2002
Posts: 579
I am currently working my way through a struts tutorial, I have a problem with the following code: String username = ((LoginForm)form).getUsername();

I get the following compilation error:
apressstruts/LoginAction.java [49:1] inconvertible types
found : org.apache.struts.action.ActionForm
required: apressstruts.LoginForm
String username = ((LoginForm)form).getUsername();
^
This is a direct snippet from the apache struts tutorial.

public ActionForward perform(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException
{
String user = null;

String target = new String("Success");

//Get parameters from the login Form

String username = ((LoginForm)form).getUsername();

return null;
}

Thanks for any help.

Tony
Tony Evans
Ranch Hand

Joined: Jun 29, 2002
Posts: 579
Sorted the problem forgot to make LoginForm extend ActionForm.

Tony
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: inconvertible types problem with struts tutorial