Re: how to retrive muliple database values and compare with jsp field vlaues
tried evry thing possibly i can... still its not working.. plz dont get angry .. iam a student we r doing a project for this i have to do this..plz help me in this...iam sending my total code..
SearchServlet:
____________
Edit your post and add to the code tags to it, it should not take more than a few minutes.
And PLEASE write the full words why do you eat up sentences with the "..." and the SMS language(used with Mobile handsets) when you have a complete keyboard in front of you.
if(mobileno.equals(request.getParameter("mno")) && password.equals(request.getParameter("pwd")))
{
out.print("<h1>You are Already Registerd </h1>");
}
else
{
out.println("<h1>You are not a Valid User Please Register</h1>");
out.println("<a href='newregister.jsp'><br>Register Here!!</a>");
}
you say this is your entire code? maybe I've missed something, but I don't see where you put the parameters pwd and mno in request, only where you try to extract them.
Re: how to retrive muliple database values and compare with jsp field vlaues
when i enter values in jsp form it has to check whether those values are present in database or not... if not present they nedd to register..i stored multiple values in Db but when iam retriving the values using resultset it is retreving the lastrow (ie;values which are inserted recently..) its not retriving other values.. here its retriving only....... 9929126444 | sdgssha | this value only..
Re: how to retrive muliple database values and compare with jsp field vlaues
Ok... Now I am going to just assume how you wish the servlet should work, If you have an already registered user, you want to just display "You are a valid user" and if the user is invalid you want to display "Please register !!".
String sql = "select mobileno,password from newuser where mobileno='"+ mobileno + "'and password='"+ password + "' " ;
Now the above query would return you a database record if and only if you got a valid user with correct mobile number and password hitting your servlet.
So instead of while(rs.next()) you should instead opt for if(rs.next()) like this :-
Re: how to retrive muliple database values and compare with jsp field vlaues
And now that I looked at it, Yes the problem IS the 'while'. I was about to say that it made no difference even if it was 'if',
BUT:
When you use While and the query doesn't return anything, the variables: 'mobileno' that are inside the while don't change value, so when later you do: if(mobileno.equals(request.getParameter("mno")) && password.equals(request.getParameter("pwd"))) It will return true even if there is no entry in the database because you use the old values that 'mobileno'
Ok... Now I am going to just assume how you wish the servlet should work, If you have an already registered user, you want to just display "You are a valid user" and if the user is invalid you want to display "Please register !!".
String sql = "select mobileno,password from newuser where mobileno='"+ mobileno + "'and password='"+ password + "' " ;
Now the above query would return you a database record if and only if you got a valid user with correct mobile number and password hitting your servlet.
So instead of while(rs.next()) you should instead opt for if(rs.next()) like this :-
And now that I looked at it, Yes the problem IS the 'while'. I was about to say that it made no difference even if it was 'if',
BUT:
When you use While and the query doesn't return anything, the variables: 'mobileno' that are inside the while don't change value, so when later you do: if(mobileno.equals(request.getParameter("mno")) && password.equals(request.getParameter("pwd"))) It will return true even if there is no entry in the database because you use the old values that 'mobileno'
Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.
This thread is more than three months old
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.