Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

saved records in a database from servlet.

 
Ritesh raushan
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 72
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 32
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 277
Flex Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Ranch Hand
Posts: 277
Flex Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Just a suggestion
setting DataSource in web.xml and then using getDataSource method for javax.sql.DataSource is better way for connecting to DataBase



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
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you so much its working...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic