File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes no getter method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "no getter method" Watch "no getter method" New topic

no getter method

rakshini nithya
Ranch Hand

Joined: Jun 15, 2006
Posts: 39
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(""));
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 (;
public void setSex(String 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="">
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

Joined: Mar 02, 2005
Posts: 580
Provide struts-config entry too
rakshini nithya
Ranch Hand

Joined: Jun 15, 2006
Posts: 39
<?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

Joined: Feb 15, 2005
Posts: 4864
Try changing:

<html:form action="">


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

Consultant, Sima Solutions
I agree. Here's the link:
subject: no getter method
It's not a secret anymore!