• 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

saved records in a database from servlet.

 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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



 
Ranch Hand
Posts: 72
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 32
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 277
Oracle Spring Flex
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Oracle Spring Flex
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you so much its working...
 
reply
    Bookmark Topic Watch Topic
  • New Topic