AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Need Help : taking data from JSP page and putting in MySQL d

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java and Databases
View previous topic :: View next topic  
Author Message
tomtumelty@gmail.com
Guest





PostPosted: Fri May 11, 2007 10:49 pm    Post subject: Need Help : taking data from JSP page and putting in MySQL d Reply with quote



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. I suspect the error is in the jsp (..maybe....)???? Any
suggestions ?

Or another thought, maybe an initialization problem? should the
variables chainName, address1, address2, city, state, zipCode,
phoneNumber be initialized to an empty string in the bean that stores
the data like this :

String chainName="";
String address1="";
String address2="";
String city="";
String state="";
String zipCode="";
String phoneNumber="";


Thanks in advance.

******************************************************************
jsp page is below :


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

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

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>
<p></p>
<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
Back to top
Philipp Taprogge
Guest





PostPosted: Sat May 12, 2007 1:14 am    Post subject: Re: Need Help : taking data from JSP page and putting in MyS Reply with quote



Hi!

Thus spake tomtumelty (AT) gmail (DOT) com on 05/11/2007 07:49 PM:
Quote:
For some reason the data entered in the jsp page is not entered in the
database. I suspect the error is in the jsp (..maybe....)???? Any
suggestions ?

Hmm... perhaps I am missing something here, but you don't seem to
include any code that would store the data into the db. This is not
done automagically for a plain old webapp. You would have to create
and execute SQL statements yourself to store the fields.
For example, you could have multiple jsps with fields and a submit
button leading to the "next" jsp. Each page would add it's fields to
the bean data. But in the end, after the last submit, you would
still have to put all that stuff into the DB.
You could either do it in a jsp or, more cleanly, write a servlet to
handle the SQL and have it redirect to a jsp after it's done.
Retrieval of a DataSource would be done through JNDI, but there are
enough good tutorials for that out there.

Another approach to that same problem would be a so-called
object-relational mapper like Hibernate that would do the SQL-stuff
for you, but that might be overkill for what you are aiming at.

HTH,

Phil
Back to top
tomtumelty@gmail.com
Guest





PostPosted: Sat May 12, 2007 2:30 am    Post subject: Re: Need Help : taking data from JSP page and putting in MyS Reply with quote



On May 11, 3:14 pm, Philipp Taprogge <Philipp.Tapro...@gmx.net> wrote:
Quote:
Hi!

Thus spake tomtume...@gmail.com on 05/11/2007 07:49 PM:

For some reason the data entered in the jsp page is not entered in the
database. I suspect the error is in the jsp (..maybe....)???? Any
suggestions ?

Hmm... perhaps I am missing something here, but you don't seem to
include any code that would store the data into the db. This is not
done automagically for a plain old webapp. You would have to create
and execute SQL statements yourself to store the fields.
For example, you could have multiple jsps with fields and a submit
button leading to the "next" jsp. Each page would add it's fields to
the bean data. But in the end, after the last submit, you would
still have to put all that stuff into the DB.
You could either do it in a jsp or, more cleanly, write a servlet to
handle the SQL and have it redirect to a jsp after it's done.
Retrieval of a DataSource would be done through JNDI, but there are
enough good tutorials for that out there.

Another approach to that same problem would be a so-called
object-relational mapper like Hibernate that would do the SQL-stuff
for you, but that might be overkill for what you are aiming at.

HTH,

Phil

The code that stores data in the database is written in stored
procedures and is called from a JavaBean. There are two beans, one
stores data and has the get and set methods. The other bean handles
the database connection and database manipulation. JDBC Mysql/
Connector J is being used to connect to the database. I should have
made this clear, thank you.

The problem seems to be getting the data from the jsp to the bean.
I keep looking at the JavaServer Pages O'Reilly book and googling but
not finding anything that helps yet.

Thak You very much.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java and Databases All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.