Hi Roshani,
Thanks a lot for helping me in this regard. As per your last reply, i Changed properties file with respect to key in the <bean:message>. when i am running the application it showing no getter method for my property.
In ActionForm my get method is getFirstname and the variable is firstName.
in the jsp page i mention my property as firstName. then it showing the error below
javax.servlet.ServletException: No getter method for property: "firstName" of bean: "strutsTutorial.UserRegistrationForm"
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:682)
org.apache.jsp.userRegistration_jsp._jspService(userRegistration_jsp.java:99)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:136)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:320)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:294)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
If i change my property to Firstname as the get method signature then it throwing the error like below
javax.servlet.ServletException: No getter method for property: "Firstname" of bean: "strutsTutorial.UserRegistrationForm"
UserRegistrationForm. java
package strutsTutorial;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionError;
import javax.servlet.http.HttpServletRequest;
public class UserRegistrationForm extends ActionForm {
private String firstName;
private String lastName;
private String userName;
private String password;
private String passwordCheck;
private String email;
private String phone;
private String fax;
private boolean registered;
public String getEmail() {
return email;
}
public void setEmail(String string) {
email = string;
}
public String getFirstname() {
return firstName;
}
public void setFirstname(String string) {
firstName = string;
}
public String getLastname() {
return lastName;
}
public void setLastname(String string) {
lastName = string;
}
public String getUsername() {
return userName;
}
public void setUsername(String string) {
userName = string;
}
public String getPassword() {
return password;
}
public void setPassword(String string) {
password = string;
}
public String getPasswordcheck() {
return passwordCheck;
}
public void setPasswordcheck(String string) {
passwordCheck = string;
}
public String getPhone() {
return phone;
}
public void setPhone(String string) {
phone = string;
}
public String getFax() {
return fax;
}
public void setFax(String string) {
fax = string;
}
public boolean getRegistered() {
return registered;
}
public void setRegistered(boolean string) {
registered = string;
}
public void reset(ActionMapping mapping,
HttpServletRequest request) {
firstName=null;
lastName=null;
userName=null;
password=null;
passwordCheck=null;
email=null;
phone=null;
fax=null;
registered=false;
}
public ActionErrors validate(ActionMapping mapping,HttpServletRequest request) {
ActionErrors errors = new ActionErrors();
if (firstName==null|| firstName.trim().equals("")){
errors.add("firstName",new ActionError("userRegistration.firstName.problem"));
}
return errors;
}
}
ApplicationResources file :
userRegistration.firstName=First Name
userRegistration.lastName=Last Name
userRegistration.userName=User Name
userRegistration.password=Password
userRegistration.email=Email
userRegistration.phone=Phone
userRegistration.fax=Fax
userRegistration.firstName.problem=The first name was blank
My JSP page is
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<html>
<head>
<title>User Registration</title>
</head>
<body>
<h1>User Registration</h1>
<html:errors/>
<table>
<html:form action="userRegistration">
<tr>
<td>
<bean:message key="userRegistration.firstName" />*
</td>
<td>
<html:text property="firstName" />
</td>
</tr>
<td>
<bean:message key="userRegistration.lastName" />*
</td>
<td>
<html:text property="lastName" />
</td>
<tr>
<td>
<bean:message key="userRegistration.userName" />*
</td>
<td>
<html:text property="username" />
</td>
</tr>
<tr>
<td>
<bean:message key="userRegistration.email" />*
</td>
<td>
<html:text property="email" />
</td>
</tr>
<tr>
<td>
<bean:message key="userRegistration.phone" />
</td>
<td>
<html:text property="phone" />
</td>
</tr>
<tr>
<td>
<bean:message key="userRegistration.fax" />
</td>
<td>
<html:text property="fax" />
</td>
</tr>
<tr>
<td>
<bean:message key="userRegistration.password" />*
</td>
<td>
<html

assword property="password" />
</td>
</tr>
<tr>
<td>
<bean:message key="userRegistration.password" />*
</td>
<td>
<html

assword property="passwordcheck" />
</td>
</tr>
<tr>
<td>
<html:submit />
</td>
<td>
<html:cancel />
</td>
</tr>
</html:form>
</table>
</body>
</html>
May be i am pasting too much code on this page. Sorry for inconvenience .
Thanks in Advance