aspose file tools*
The moose likes Struts and the fly likes Exception in struts Application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Exception in struts Application" Watch "Exception in struts Application" New topic
Author

Exception in struts Application

kittu karan
Ranch Hand

Joined: Mar 09, 2008
Posts: 63
Hi,
I wrote a application to take data from register.jsp and store all values in database(MySQL),I wrote form beans and actions programs I am getting this error when I am clicking on submit button of register.jsp:

javax.servlet.ServletException: No getter method for property username of bean org.apache.struts.taglib.html.BEAN

org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:862)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:795)
org.apache.jsp.login_jsp._jspService(login_jsp.java:105)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)


root cause

javax.servlet.jsp.JspException: No getter method for property username of bean org.apache.struts.taglib.html.BEAN
org.apache.struts.util.RequestUtils.lookup(RequestUtils.java:742)
org.apache.struts.taglib.html.BaseFieldTag.doStartTag(BaseFieldTag.java:193)
org.apache.jsp.login_jsp._jspx_meth_html_text_1(login_jsp.java:502)
org.apache.jsp.login_jsp._jspx_meth_html_form_0(login_jsp.java:148)
org.apache.jsp.login_jsp._jspService(login_jsp.java:93)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
Gowher Naik
Ranch Hand

Joined: Feb 07, 2005
Posts: 643
The exception specifies clearly that there is No getter method for property username.Check out your ActionForm bean class for username property.
kittu karan
Ranch Hand

Joined: Mar 09, 2008
Posts: 63
Hi,
this is login.jsp code

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>

<html>
</head>
<title>registration form</title>
</head>
<body bgcolor="wheat">
<br>
<center><h2>Registration Form</h2></center>
<center>
<html:form action="/login">
<html:errors/>
<table border="0" align="center">

<tr>
<td>Name<span class="mandatory"></span></td><br></br>
<td><html:text property="name" maxlength="20"/></td>

</tr>


<tr>
<td>Username<span class="mandatory">*</span></td>
<td><html:text property="uname"/></td>
</tr>

<tr>
<td>Password<span class="mandatory">*</span></td>
<td><html assword property="password" maxlength="25"/></td>
</tr>

<tr>
<td>ConfirmPassword<span class="mandatory">*</span></td>
<td><html assword property="repassword" maxlength="25"/></td>
</tr>
<tr>

<td>Date of Birth </td>
<td><html:text property="dob" maxlength="25"/>
<!-- <SELECT style="width:55px;font-family: MS Sans serif, arial, Verdana, sans-serif;font-size : 9pt" >

<option value="">DD
<option value="1" >1
<option value="2" >2
<option value="3" >3
<option value="4" >4
<option value="5" >5
<option value="6" >6
<option value="7" >7
<option value="8" >8
<option value="9" >9
<option value="10" >10
<option value="11" >11
<option value="12" >12
<option value="13" >13
<option value="14" >14
<option value="15" >15
<option value="16" >16
<option value="17" >17
<option value="18" >18
<option value="19" >19
<option value="20" >20
<option value="21" >21
<option value="22" >22
<option value="23" >23
<option value="24" >24
<option value="25" >25
<option value="26" >26
<option value="27" >27
<option value="28" >28
<option value="29" >29
<option value="30" >30
<option value="31" >31
</select>

<SELECT style="width:55px;font-family: MS Sans serif, arial,Verdana, sans-serif;font-size : 9pt">
<option value="">MM
<option value="1" >1
<option value="2" >2
<option value="3" >3
<option value="4" >4
<option value="5" >5
<option value="6" >6
<option value="7" >7
<option value="8" >8
<option value="9" >9
<option value="10" >10
<option value="11" >11
<option value="12" >12
</select>

<SELECT style="width:55px;font-family: MS Sans serif, arial, Verdana, sans-serif;font-size : 9pt">
<option value="">YYYY
<option value="2008" >2008
<option value="2007" >2007
<option value="2006" >2006
<option value="2005" >2005
<option value="2004" >2004
<option value="2003" >2003
<option value="2002" >2002
<option value="2001" >2001
<option value="2000" >2000
<option value="1999" >1999
<option value="1998" >1998
<option value="1997" >1997
<option value="1996" >1996
<option value="1995" >1995
<option value="1994" >1994
<option value="1993" >1993
<option value="1992" >1992
<option value="1991" >1991
<option value="1990" >1990
<option value="1989" >1989
<option value="1988" >1988
<option value="1987" >1987
<option value="1986" >1986
<option value="1985" >1985
<option value="1984" >1984
<option value="1983" >1983
<option value="1982" >1982
<option value="1981" >1981
<option value="1980" >1980
<option value="1979" >1979
<option value="1978" >1978
<option value="1977" >1977
<option value="1976" >1976
<option value="1975" >1975
<option value="1974" >1974
<option value="1973" >1973
<option value="1972" >1972
<option value="1971" >1971
<option value="1970" >1970
<option value="1969" >1969
<option value="1968" >1968
<option value="1967" >1967
<option value="1966" >1966
<option value="1965" >1965
<option value="1964" >1964
<option value="1963" >1963
<option value="1962" >1962
<option value="1961" >1961
<option value="1960" >1960
<option value="1959" >1959
<option value="1958" >1958
<option value="1957" >1957
<option value="1956" >1956
<option value="1955" >1955
<option value="1954" >1954
<option value="1953" >1953
<option value="1952" >1952
<option value="1951" >1951
<option value="1950" >1950
</select> -->
<font size="1" color="#7D7D7D"></font>
</td>
</tr>
<tr>
<td>Gender</td>
<td valign="top" class="text1" colspan="2">
<html:radio property="gender" value="F"/>Female   
<html:radio property="gender" value="M"/>Male
</td>
</tr>
<tr>
<td>Blood Group*</td>
<td colspan="2">
<html:text property="bloodgroup"/></td> </tr>
<tr><td>Weight*</b></td>
<td><html:text property="weight"/> Kgs<br></td>
</tr>
<tr>
<td>Mobile</td>
<td>
<table border="0">
<tr><td valign="top" align="center"><br><html:text property="mobileno"/></td></tr>
<!--<tr><td valign="top" align="center">Res<br><html:text property="res1"/></td></tr>
<td valign="top" align="center">Off<br><html:text property="off1"/></td>
</tr>--></table>
</td>

</tr>
<tr>
<td>E-mail id*</td>
<td>
<html:text size="20" property="email"/><br>
</td>


</td>
</tr>

<td>State</td>
<td colspan="2">
<html:text property="state"/>
<!--<SELECT style="width:150px;font-family:Verdana;font-size : 9pt" name="state" size="1">
<option value="">select state</td>
</tr>
<tr>
<td>City</td>
<TD colspan="2">
<SELECT style="width:150px;font-family:Verdana;font-size : 9pt" property="city" size="1">
<option value=""><b>Select City</b>
</select> -->
</td>
</tr>

<tr>
<td>Area</td>
<td colspan="2"><html:text property="area"/>
<!--<SELECT style="width:200px;font-family:Verdana;font-size : 9pt" name="town" size="1">
<option value="">Select Area
</select>
</td>-->
</tr>
<tr><!--
<td>Blood Group</td>
<td colspan="2">
<html:text property="bloodgroup"/>

<SELECT style="width:75px;font-family:Verdana;font-size : 9pt" property="bloodgroup" size="1">
<option value="">Select
<option value="1" > A1+
<option value="2" > A1-
<option value="3" > A2+
<option value="4" > A2-
<option value="5" > B+
<option value="6" > B-
<option value="7" > A1B+
<option value="8" > A1B-
<option value="9" > A2B+
<option value="10" > A2B-
<option value="11" > AB+
<option value="12" > AB-
<option value="13" > O+
<option value="14" > O-
<option value="15" > A+
<option value="16" > A-
</select> -->
</td>
</tr>
<center>
<tr>
<td><br><html:submit>Register</html:submit>
<html:reset>reset</html:reset>
<!--<input type="submit" value="submit" property="btnSubmit">
<input type="reset" value="Reset" property="btnReset"> -->
</td>
</tr>
</center>

</table>
</html:form>
</center>
</body>
</html>


// LoginForm code

package com.arvensys.work;

import org.apache.struts.action.*;
import javax.servlet.http.*;


/**
* @version jdk 1.5 03 April 2008
* @author Kiran Kumar
* This class is for
*/

public class LoginForm extends ActionForm {


String name,uname,password,repassword,gender,email,state,city,area,bloodgroup;
int dob,weight,mobileno;

/** Here all setter and getter methods in registration form */

public void setName(String name) {
this.name=name;
}

public String getName() {
return name;
}

public void setUserName(String uname) {
this.uname=uname;
}

public String getUserName() {
return uname;
}

public void setPassword(String password) {
this.password =password;
}

public String getPassword() {
return password;
}

/*public void setRePassword(String password) {
this.repassword =repassword;
}

public String getRePassword() {
return repassword;
}
*/

public void setGender(String gender) {
this.gender=gender;
}

public String getGender() {
return gender;
}

public void setDoB(int dob) {
this.dob =dob;
}

public int getDoB() {
return dob;
}

public void setWeight(int weight) {
this.weight=weight;
}

public int getWeight(){
return weight;
}

public void setEmail(String email) {
this.email=email;
}

public String getEmail(){
return email;
}

public void setBloodGroup(String bloodgroup) {
this.bloodgroup=bloodgroup;
}

public String getBloodGroup() {
return bloodgroup;
}

public void setState(String state) {
this.state=state;
}

public String getState(){
return state;
}

public void setCity(String city) {
this.city=city;
}

public String getCity() {
return city;
}


public void setArea(String area) {
this.area=area;
}

public String getArea() {
return area;
}

public void setMobileNo(int mobileno) {
this.mobileno=mobileno;
}

public int getMobileNo() {
return mobileno;
}


/**
* Validate the properties that have been sent from the HTTP request,
* and return an ActionErrors object that encapsulates any
* validation errors that have been found. If no errors are found, return
* an empty ActionErrors object.
*/

// This method validates register form

public ActionErrors validate(ActionMapping mapping,HttpServletRequest request) {
System.out.println("inside ActionErrors");
ActionErrors ae=new ActionErrors();

// Here to perform validators
/*
If this method returns 'null' or empty ActionErrors object then RequestProcessor considers that the validation is successful if not validation is failed
*/
if((uname==null) || (uname.equals("")))
ae.add("registerform",new ActionError("username.empty"));
System.out.println("after username validations");

if((password==null) || (password.equals("")) || (repassword==null) || (repassword.equals(""))) {
ae.add("registerform", new ActionError("password.empty"));
System.out.println("after password validations");
} else if(!password.equals(repassword)){
ae.add("registerform",new ActionError("repass.notequal"));
System.out.println("after repassword validations");
}
System.out.println("before return");
System.out.println(ae);
return ae;
}// validate method


public void reset(ActionMapping mapping, HttpServletRequest request) {

/** Because this ActionForm should be request scope, do nothing here because
* the fields will be reset when a new instance is created. We could
* have just not override the parent reset() method, but did so just
* to provide an example of the reset() method signature.
*/
System.out.println("inside reset");
}// reset method
}// LoginForm


Can you please tell me what is the error in this code.

Thanks in advance.
Gowher Naik
Ranch Hand

Joined: Feb 07, 2005
Posts: 643
Hi kiran peruka
It will be better to create login page and login form bean with couple of fields only.Once your simple login page will work properly then you can add all other fields.It is difficult to check such a long list of code.
Anubhav Anand
Ranch Hand

Joined: May 18, 2007
Posts: 341

Please use code tags for posting code. It makes the post much more readable.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Exception in struts Application