• 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 ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

I am unable to find error in this program.

 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This login.html for registration form

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

<tr>
<td>Name<span class="mandatory"></span></td><br></br>
<td><input type="text" name="name" maxlength="20"></td>

</tr>


<tr>
<td>UserName<span class="mandatory">*</span></td>
<td><input type="text" name="username" maxlength="20"></td>
</tr>

<tr>
<td>Password<span class="mandatory">*</span></td>
<td><input type="password" name="password" maxlength="25"></td>
</tr>

<tr>
<td>ConfirmPassword<span class="mandatory">*</span></td>
<td><input type="password" name="repassword" maxlength="25"></td>
</tr>
<tr>

<td>Date of Birth </td>
<td><input type="text" name="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">
<input type="radio" name="gender" value="F" >Female   
<input type="radio" name="gender" value="M" >Male
</td> -->
</tr>
<tr>
<td>Blood Group*</td>
<td colspan="2">
<input type="text" name="bloodgroup" size=5 maxlength=3></td> </tr>
<tr><td>Weight*</b></td>
<td><input type="text" name="weight" size=5 maxlength=3> Kgs<br></td>
</tr>
<tr>
<td>Mobile</td>
<td>
<table border="0">
<tr><td valign="top" align="center"><br><INPUT TYPE="text" NAME="mobileno" value=""></td></tr>
<!--<tr><td valign="top" align="center">Res<br><INPUT TYPE="text" NAME="res1" value=""></td></tr>
<td valign="top" align="center">Off<br><INPUT TYPE="text" NAME="off1" value=""></td>
</tr>--></table>
</td>

</tr>
<tr>
<td>E-mail id*</td>
<td>
<input type="text" size="20" NAME="email" value="" ><br>
</td>


</td>
</tr>

<td>State</td>
<td colspan="2">
<input type="text" name="state" size=5 maxlength=3>
<!--<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" NAME="city" size="1">
<option value=""><b>Select City</b>
</select> -->
</td>
</tr>

<tr>
<td>Area</td>
<td colspan="2"><input type="text" name="area" size=5 maxlength=3>
<!--<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">
<input type="text" name="bloodgroup" size=5 maxlength=3>

<SELECT style="width:75px;font-family:Verdana;font-size : 9pt" NAME="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>
<input type="submit" value="submit" name="btnSubmit">
<input type="reset" value="Reset" name="btnReset">
</td>
</tr>
</center>

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

//web-inf
<web-app>
<servlet>
<servlet-name>actionservlet</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>actionservlet</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
</web-app>

//struts-config.xml
<struts-config>
<form-beans>
<form-bean name="lf" type="com.arvensys.work.LoginForm"/>
</form-beans>
<action-mappings>
<action path="/login" type="com.arvensys.work.LoginServlet" name="lf" scope="session" validate="true" input="/login.html">
<forward name="success" path="/response.jsp"/>
<forward name="failure" path="/error.jsp"/>
</action>
</action-mappings>
<message-resources parameter="Application-Resources"/>
</struts-config>

//loginform.java This is class is for form bean

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,username,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 username) {
this.username=username;
}

public String getUserName() {
return username;
}

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((username==null) || (username.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 overrode 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



// LoginAction servlet

package com.arvensys.work;

import org.apache.struts.action.*;
import javax.servlet.http.*;
import java.io.*;
import java.sql.*;




public class LoginServlet extends Action {

public ActionForward execute(ActionMapping am,ActionForm af,
HttpServletRequest request,HttpServletResponse response) throws Exception {
System.out.println("before casting");
LoginForm lf=(LoginForm)af;
System.out.println("after casting");
try{
System.out.println("in try");
String userName = "root";
String password = "arvensys";
String url = "jdbc:mysql://localhost:3306/bloodbank";
Class.forName ("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection (url,userName,password );
System.out.println ("Database connection established");
String sqlstatement="insert into donortable values(?,?,?,?,?,?,?,?,?,?,?,?)";
PreparedStatement ps=con.prepareStatement(sqlstatement);


ps.setString(1,lf.getName());
ps.setString(2,lf.getUserName());
ps.setString(3,lf.getPassword());
ps.setString(4,lf.getGender());
ps.setString(5,lf.getBloodGroup());
ps.setInt(6,lf.getWeight());
ps.setInt(7,lf.getDoB());
ps.setInt(8,lf.getMobileNo());
ps.setString(9,lf.getEmail());
ps.setString(10,lf.getArea());
ps.setString(11,lf.getCity());
ps.setString(12,lf.getState());


if(ps.executeUpdate()==1)
return am.findForward("success");
} catch (Exception e) {
e.printStackTrace();
System.out.println ("Cannot connect to database server");
}// catch
returnam.findForward("failure");
}
}

I created struts folders no errors while compiling when I run this appplication on tomcat 5.0 server its again showing errors. please help me

Thanks in advance.
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just saying your application is "showing errors" doesn't tell us anything that would be useful in helping you solve the problem. This link may help you determining what we need to know.
 
kittu karan
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When I deployed this application on tomcat 5.0,when I am entering the details in login.html its again showing login.html only. I wrote System.out.printn statements in formbeans and Action programs it returning action errors obj but it doenot entering into the LoginAction class where I wrote database operation to store all the form data into MySQL database I created database and tables also. but it showing login.html Please try to deploy this application run on server you will know above mentioned problem clearly.
thanks in advance.
 
Ranch Hand
Posts: 341
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Using code tags and other UBB tags makes the post much more readable. Please have a look at this link.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My first recommendation would be to change login.html to login.jsp and change all input tags to struts tags. The way it is currently, if there's an error on the page, the values entered by the user will disappear when the page is returned. You will also need to add an <html:errors /> tag to the page so that any error messages generated will be displayed.
 
kittu karan
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I gave html tags in login.html and change login.html as login.jsp when I entered registration form after clicking submit it again showing same page. please help me.
thanks in advance.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please post your login.jsp page. I'm particularly interested in seeing your html:form tag.
 
kittu karan
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
This is my login.jsp page 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="username"/></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>


I deployed my application I am getting this error in the following:


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)


Thanks in advance.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The problem is with the following line:

The property is misspelled. It should be userName instead of username.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic