• Post Reply Bookmark Topic Watch Topic
  • New Topic

no getter method  RSS feed

rakshini nithya
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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" %>

<head><title>Submit example</title></head>

<h3>Example Submit Page</h3>


<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>

<logic resent name="lastName" scope="request">
<logic:equal name="submitForm" property="age" value="a">
<logic:equal name="submitForm" property="age" value="c">
<logic:equal name="submitForm" property="sex" value="M">
<logic:equal name="submitForm" property="sex" value="F">
<bean:write name="lastName" scope="request"/>
</logic resent>

vidya sagar
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Provide struts-config entry too
rakshini nithya
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<?xml version="1.0" encoding="ISO-8859-1" ?>

<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.0//EN"


<!-- ========== Form Bean Definitions ================= -->

<form-bean name="submitForm"


<!-- ========== Action Mapping Definitions ============ -->

<action path="/submit"
<forward name="success" path="/submit.jsp"/>
<forward name="failure" path="/submit.jsp"/>


Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try changing:

<html:form action="submit.do">


<html:form action="/submit">

If Struts can't match up the action path specified in the <html:form> tag to an action in the config file, it won't be able to find and instantiate the proper ActionForm bean. Sometimes it will find it even with the ".do" at the end, but I've found it's best to specify the action in the <html:form> exactly as it's defined in the struts-config.xml file.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!