• 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

Variable is not getting transferred from controller servlet to model

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am accepting username and password from user and comparing it with database value.
Here is my controller code ----->



And I have created database connection in model and fetching password according to the username entered by user.
Here is my model ----->



Both controller and model are in the same package.
But either model is not receiving the username or it is not getting executed at all..... I am not able to find out the error..
Please help..
 
author & internet detective
Posts: 41878
909
Eclipse IDE VI Editor Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try adding a debug statement. In particular both before and after rs.next so you can see what it gets up to.

Also a few learning notes before you take this into the real world:
  • Use a PreparedStatement - search for SQL Injection to read about what someone can do with your code
  • Include the password in the database query's prepared statement so you aren't passing in around
  • Encrypt the password
  • Close your database resources in a finally block so you don't run out of connections
  •  
    Ranch Hand
    Posts: 153
    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
    Hi Arti,

    Seems you are new in the Java and have written good modularized code though some more modifications need to do .

    Follow what Jeanne has suggested.

    One very minute mistake i am observing is your servlet don't have doGet() or doPost() methods which is very important to get data from your request .

    See what exactly happens is when you are submitting the form having method="get" or "post" then all form parameters/data goes to your request and then to the servelet method doGet() or doPost() where you can process request data.

    So you need to add doGet() or doPost() method based on your form method and then can processRequest() from it .

    Please refer the below link for more details

    http://www.jguru.com/faq/view.jsp?EID=1307699


    - Chetan
     
    Consider Paul's rocket mass heater.
    reply
      Bookmark Topic Watch Topic
    • New Topic