• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Struts: No getter method for property name problem

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone,
I am new to this struts. I have a samll application to check login. When I run my application I get this message in my server console
No getter method for property user of bean org.apache.struts.taglib.html.BEAN
I saw the previous forum for the same topic. I have checked my property names start with appropriate cases. Here is my code
%@ page language="java" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>

<html>
<head><title>Login</title></head>
<body>
<html:form action="submit.do">
<table width="100%" border="0" height=75%>
<tr>
<td align="right" >UserName: </td>
<td><html:text property="user"/></td>
<tr>
<tr>
<td align="right" >Password: </td>
<td><html:text property="password"/></td>
</tr>
<tr>
<td colspan=2 align="center"><html:submit/></td>
</tr>
<tr>
<td colspan=2 align="center"><html:errors/></td>
</tr>
</table>
</html:form>

</body>
</html>
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.*;
import java.util.*;
/**
* @author skannan
*
* To change this generated comment edit the template variable "typecomment":
* Window>Preferences>Java>Templates.
* To enable and disable the creation of type comments go to
* Window>Preferences>Java>Code Generation.
*/
public class LoginForm extends ActionForm
{

private String user = null;
private String password = null;

/* user */
public String getUser()
{
return (this.user);
}
public void setUser(String user)
{
this.user = user;
}

/* password */
public String getPassword()
{
return (this.password);
}
public void setPassword(String password)
{
this.password = password;
}
public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {
// Log the forms data
servlet.log("Lastname:" + user);
servlet.log("Address:" + password);


// Check for mandatory data
ActionErrors errors = new ActionErrors();
if (user == null || user.equals("")) {
errors.add("User", new ActionError("error.user"));
}
if (password == null || password.equals("")) {
errors.add("Password", new ActionError("error.password"));
}

return errors;
}
}
I am missing anything in my config files. Please I need help.
Thanks!
 
Sujatha Kannan
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I found the problem and fixed it.
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hai,

I am having similar problem can u pls suggest me
 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please, poste your action-mapping, your jsp(particularry the html:form) and your form bean.

In my expirence, this message results mainly through a mismatch in the configuration. struts looks for the action-mapping, which is with the <html:form action="" /> definied. then it looks for the specified formbean and tries to match all your form-elements with a getter/setter of the form-bean.

For example, if you have a spelling mismatch by a propertie, then you get this error.

stefan
 
reply
    Bookmark Topic Watch Topic
  • New Topic