Meaningless Drivel is fun!*
The moose likes JDBC and the fly likes Variable is not getting transferred from controller servlet to model Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Variable is not getting transferred from controller servlet to model" Watch "Variable is not getting transferred from controller servlet to model" New topic
Author

Variable is not getting transferred from controller servlet to model

Arati nargide
Greenhorn

Joined: Mar 19, 2012
Posts: 3
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..
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30050
    
149

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


  • [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
    Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
    Karn Kumar
    Ranch Hand

    Joined: Aug 06, 2009
    Posts: 145

    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
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Variable is not getting transferred from controller servlet to model
     
    Similar Threads
    Servlet help
    how to keep register page data if register fails
    How to separate Business Logic from the servlet
    Login/Logout Problem
    user authentication and dao