This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

No Getter method for LastName property of bean

 
Ramkumar Ramasubbu
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am new to struts. I tried to run a simple struts application.
I am getting the following error.
javax.servlet.ServletException: No getter method for property LastName of bean org.apache.struts.taglib.html.BEAN
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:495)
at org.apache.jsp.submit_jsp._jspService(submit_jsp.java:97)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:92)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:809)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:162)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:240)


But i have getter/setter method for the property LastName.

Here is the SubmitForm class

package hansen.playground;
import org.apache.struts.action.ActionForm;


/**
* @author rramasub
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public final class SubmitForm extends ActionForm {

private String LastName = "Hansen";
private String Address;
private String Sex;
private String Age;

/**
* @return Returns the address.
*/
public String getAddress() {
return Address;
}
/**
* @param address The address to set.
*/
public void setAddress(String address) {
Address = address;
}
/**
* @return Returns the age.
*/
public String getAge() {
return Age;
}
/**
* @param age The age to set.
*/
public void setAge(String age) {
Age = age;
}
/**
* @return Returns the lastName.
*/
public String getLastName() {
return LastName;
}
/**
* @param lastName The lastName to set.
*/
public void setLastName(String lastName) {
LastName = lastName;
}
/**
* @return Returns the sex.
*/
public String getSex() {
return Sex;
}
/**
* @param sex The sex to set.
*/
public void setSex(String sex) {
Sex = sex;
}
}


Here is the Action class

package hansen.playground;
import org.apache.struts.action.ActionForm;


/**
* @author rramasub
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public final class SubmitForm extends ActionForm {

private String LastName = "Hansen";
private String Address;
private String Sex;
private String Age;

/**
* @return Returns the address.
*/
public String getAddress() {
return Address;
}
/**
* @param address The address to set.
*/
public void setAddress(String address) {
Address = address;
}
/**
* @return Returns the age.
*/
public String getAge() {
return Age;
}
/**
* @param age The age to set.
*/
public void setAge(String age) {
Age = age;
}
/**
* @return Returns the lastName.
*/
public String getLastName() {
return LastName;
}
/**
* @param lastName The lastName to set.
*/
public void setLastName(String lastName) {
LastName = lastName;
}
/**
* @return Returns the sex.
*/
public String getSex() {
return Sex;
}
/**
* @param sex The sex to set.
*/
public void setSex(String sex) {
Sex = sex;
}
}

Here is the Struts-Config.xml file

<struts-config>

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

<form-bean name="SubmitForm" type="hansen.playground.SubmitForm"/>

</form-beans>

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

<action path="/submit" type="hansen.playground.ActionClass"
name="SubmitForm"
scope="request">
<forward name="success" path="/submit.jsp"/>
<forward name="failure" path="/submit.jsp"/>
</action>
</action-mappings>

</struts-config>


I dont Know why i am getting this error.

Can anyone help me to resolve this issue?

Thanks for all your responses.


Regards
Ramkumar
 
Vasudhaiv Naresh
Ranch Hand
Posts: 57
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ram!
I guess the ActionForm does not follow the bean's convention of naming properties:
->each property must begin with a lower case alphabet, and in case the property name has two words, the second word must begin with an upper case character.
Check replacing "LastName" property with "lastName".
Regards,
Naresh
 
Aash Patel
Greenhorn
Posts: 24
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree with Naresh!
 
Ramkumar Ramasubbu
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Naresh and Patel,

Thanks for your response. But i tried the solution you gave. It's also giving me the same error.
Is there any other solution for this? If yes please help me withe solution.
 
S Bhanu
Greenhorn
Posts: 15
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can u send the code snippet u r using in html?
 
Ramkumar Ramasubbu
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Bhanu,

here is the code snippet for jsp page


<%@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>SubmitExample</title></head>
<body>

<h2>Example Submit Pageeeee</h2>


<html:errors/>
<html:form action = "submitPage">

Address: <html:textarea property = "address"/><br>
Sex: <html:radio property = "sex" value = "M"/>Male
<html:radio property = "sex" value = "F"/>Female<br>
Age: <html:select property = "age"/>
<htmlption value = "a">0-19</htmlption>
<htmlption value = "b">20-49</htmlption>
<htmlption value = "c">50-</htmlption>
</html:select><br>
<html:submit/>
</html:form>


</body>
</html>



Thanks for your efforts
 
Ergin Er
Ranch Hand
Posts: 60
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It looks like you have cofigured the form bean as submitForm in struts config, but that you are calling a form named submitPage (which doesn't exist). Could you try changing that into submitForm?
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic