| Author |
saved records in a database from servlet.
|
Ritesh raushan
Ranch Hand
Joined: Aug 29, 2012
Posts: 97
|
|
i am beginner .
1-i have created servlet program which takes username,password,hobby,gender and saved in a database .
but except username all saved(username column is blank for every entry and all other column filled).
2-i have commented on the statement of(if(password.equals("cnfrmPassword")) and at last i wrote a else statement) matching password and conform password and when i uncommented then always output come that (password and confrmpassword didn't match)even i give same password..
please help me.
thanks
|
 |
nir sharma
Ranch Hand
Joined: Sep 11, 2012
Posts: 72
|
|
post your jsp file also.
(if(password.equals("cnfrmPassword"))
here cnfrmPassword is treated as a string and not a variable.
this should be :
Also try to debug and check whether you are getting username value in servlet from jsp or not.
|
 |
Saket Kumar Sinha
Ranch Hand
Joined: Aug 04, 2011
Posts: 31
|
|
Just a suggestion
setting DataSource in web.xml and then using getDataSource method for javax.sql.DataSource is better way for connecting to DataBase
|
 |
Ashwin Sridhar
Ranch Hand
Joined: Jul 09, 2011
Posts: 272
|
|
|
Probably the name of the username field and the one you are using in the getParameter may be different. Try debugging by using System.out after you receive the parameters in your servlet.
|
Ashwin Sridhar
SCJP | SCWCD | OCA
|
 |
Ashwin Sridhar
Ranch Hand
Joined: Jul 09, 2011
Posts: 272
|
|
Using a datasource would be efficient in case of multiple connections. in the sense when you have a pool of connections and want them to be used judiciously.
In case of single connection, I would connect using DriverManager.
Correct me if am wrong.
|
 |
Ritesh raushan
Ranch Hand
Joined: Aug 29, 2012
Posts: 97
|
|
|
thank you so much its working...
|
 |
 |
|
|
subject: saved records in a database from servlet.
|
|
|