Win a copy of Rust Web Development this week in the Other Languages forum!
  • 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 ...
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

no getter method

Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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(""));
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>

Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Provide struts-config entry too
rakshini nithya
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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"/>


Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic