jsp and beans

I am using Sun JDK 1.5.0_09, Tomcat 5.5.17, MySQL 5.0 .

I am gathering data from a webpage using jsp. Beans are handling the database operations. I have tested the Bean code and it correctly adds data to the database table.

For some reason the data entered in the jsp page is not entered in the database so i suspect the error is in the jsp (..maybe....)?

Any suggestions ? Thanks in advance.

The jsp code is below :

AddChain.jsp

******************************************************************************

<jsp:useBean id="ChainInfoBean" class="com.bean.ChainInfoBean" scope="request"/>

<jsp:useBean id="GiftData" class="com.bean.dataBase" scope="session" />

<jsp:setProperty name="ChainInfoBean" property="*"/>

<html>

<head><title>Add Chain</title></head>

<body bgcolor="white">

<h2>Chain Information</h2>

<form ACTION="../gift/AddChain.jsp" method=POST>

<P>

Chain Name <input type="text" name="chainName" value="" size=50 maxlength=50>

<P>

Address 1 <input type="text" name="address1" value="" size=50 maxlength=50>

<P>

Address 2 <input type="text" name="address2" value="" size=50 maxlength=50>

<P>

City <input type="text" name="city" value="" size=50 maxlength=50>

<P>

State <input type="text" name="state" value="" size=2 maxlength=2>

<P>

Zipcode <input type="text" name="zipCode" value="" size=9 maxlength=9>

<P>

Phone Number <input type="text" name="phoneNumber" value="" size=10 maxlength=10>

<input type="submit" value="Submit">

<input type="reset" value="Reset">

</form>

<%

if (request.getMethod().equals("POST") ) {

out.println("POST");

String [] results;

// String ResponseCode;

GiftData.init();

results = GiftData.addChain("E",

ChainInfoBean.getchainName(),

ChainInfoBean.getaddress1(),

ChainInfoBean.getaddress2(),

ChainInfoBean.getcity(),

ChainInfoBean.getstate(),

ChainInfoBean.getzipCode(),

ChainInfoBean.getphoneNumber()

);

}

%>

</body>

</html>

[2384 byte] By [chrootmana] at [2007-11-27 4:03:46]
# 1
well... i'd like to help you, but you should read this link before posting http://forum.java.sun.com/help.jspa?sec=formattingIt's impossible to read the way it is
YasuDevila at 2007-7-12 9:08:34 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

Sorry about the formatting perviusly, I hope this is better.

I am using Sun JDK 1.5.0_09, Tomcat 5.5.17, MySQL 5.0 .

I am gathering data from a webpage using jsp.

Beans are handling the database operations. I have tested the Bean code and it correctly adds data to the database table.

For some reason the data entered in the jsp page is not entered in the database so i suspect the error is in the jsp (..maybe....)?

Any suggestions ? Thanks in advance.

The jsp code is below :

AddChain.jsp ******************************************************************************

<jsp:useBean id="ChainInfoBean" class="com.bean.ChainInfoBean" scope="session"/>

<jsp:useBean id="AddStoreChain" class="gift.dataBase" />

<jsp:setProperty name="ChainInfoBean" property="*"/>

<html>

<head><title>Add Chain</title></head>

<body bgcolor="white">

<h2>Chain Information</h2>

<form method="get" ACTION="../gift/AddChain.jsp">

<P>

Chain Name <input type="text" name="chainName" size="50">

<P>

Address 1 <input type="text" name="address1" size="50">

<P>

Address 2 <input type="text" name="address2" size="50">

<P>

City <input type="text" name="city" size="50">

<P>

State <input type="text" name="state" size="2">

<P>

Zipcode <input type="text" name="zipCode" size="9">

<P>

Phone Number <input type="text" name="phoneNumber" size="10">

<input type="submit" value="Submit">

<input type="reset" value="Reset">

</form>

<%

String [] results;

String ResponseCode;

AddStoreChain.init();

results = AddStoreChain.addChain("E",

ChainInfoBean.getchainName(),

ChainInfoBean.getaddress1(),

ChainInfoBean.getaddress2(),

ChainInfoBean.getcity(),

ChainInfoBean.getstate(),

ChainInfoBean.getzipCode(),

ChainInfoBean.getphoneNumber()

);

%>

</body>

</html>

chrootmana at 2007-7-12 9:08:34 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
Make sure that the getters and setters match what's in the bean file. Make sure that there is a property called 'chainName' and not 'ChainName'.
C_Walkera at 2007-7-12 9:08:34 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
Post your backing bean. Also capitalise the first letter after get in all the methods eg getchainName should be getChainName. This is the standard javabean syntax.
josephquinn80a at 2007-7-12 9:08:34 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...