Hi am getting this following error
javax.servlet.ServletException: No getter method for property lastName of bean org.apache.struts.taglib.html.BEAN
My Form is
public class SubmitForm extends ActionForm {
private
String lastName = "Hansen"; // default value
private String address = null;
private String sex = null;
private String married = null;
private String age = null;
public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {
// Log the forms data
servlet.log("Lastname:" + lastName);
servlet.log("Address:" + address);
servlet.log("Sex:" + sex);
servlet.log("Married:" + married);
servlet.log("Age:" + age);
// Check for mandatory data
ActionErrors errors = new ActionErrors();
if (lastName == null || lastName.equals("")) {
errors.add("Last Name", new ActionError("error.lastName"));
}
if (address == null || address.equals("")) {
errors.add("Address", new ActionError("error.address"));
}
if (sex == null || sex.equals("")) {
errors.add("Sex", new ActionError("error.sex"));
}
if (age == null || age.equals("")) {
errors.add("Age", new ActionError("error.age"));
}
return errors;
}
/* Last Name */
public String getLastName() {
return (this.lastName);
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
/* Address */
public String getAddress() {
return (this.address);
}
public void setAddress(String address) {
this.address = address;
}
/* Sex */
public String getSex() {
return (this.sex);
}
public void setSex(String sex) {
this.sex = sex;
}
/* Married status */
public String getMarried() {
return (this.married);
}
public void setMarried(String married) {
this.married = married;
}
/* Age */
public String getAge() {
return (this.age);
}
public void setAge(String age) {
this.age = age;
}
}
My
jsp is
<%@ page language="java" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<html>
<head><title>Submit example</title></head>
<body>
<h3>Example Submit Page</h3>
<html:errors/>
<html:form action="submit.do">
Last Name: <html:text property="lastName"/><br>
Address: <html:textarea property="address"/><br>
Sex: <html:radio property="sex" value="M"/>Male
<html:radio property="sex" value="F"/>Female<br>
Married: <html:checkbox property="married"/><br>
Age: <html:select property="age">
<html
ption value="a">0-19</html
ption>
<html
ption value="b">20-49</html
ption>
<html
ption value="c">50-</html
ption>
</html:select><br>
<html:submit/>
</html:form>
<logic
resent name="lastName" scope="request">
Hello
<logic:equal name="submitForm" property="age" value="a">
young
</logic:equal>
<logic:equal name="submitForm" property="age" value="c">
old
</logic:equal>
<logic:equal name="submitForm" property="sex" value="M">
Man
</logic:equal>
<logic:equal name="submitForm" property="sex" value="F">
Lady
</logic:equal>
<bean:write name="lastName" scope="request"/>
</logic
resent>
</body>
</html>