0

Hi all,
when I use equals method is not working when i tried to check password from database and from textfeild both the values are same but eqals method shows error
my code is

if(strPasswordNew.equals(passwordManager.getPassword()))

My complete code for rreference

String strPasswordOld=request.getParameter("oldpassword");
        String strPasswordNew=(request.getParameter("newpassword")).trim();
        String strPasswordNew1=(request.getParameter("newpassword1")).trim();
        if(strPasswordNew.length()!=0 && strPasswordNew.equals(strPasswordNew1)){
            dataManager.getConnection();
            PasswordManager passwordManager =new PasswordManager();
            passwordManager=dataManager.getPassword(strUserId);
            if(strPasswordNew.equals(passwordManager.getPassword())){
                dataManager.changePassword(strUserId,strPasswordNew);
                session.setAttribute("error", "Password Changed Successfully");
                response.sendRedirect("/CMS/editdetails.jsp");

            }
            else{
                session.setAttribute("error","Password Doesnot match with your DB");
                response.sendRedirect("/CMS/editdetails.jsp");
            }


        }
        else{
            out.print("error");
            session.setAttribute("error", "password mismatch");
            response.sendRedirect("/CMS/editdetails.jsp");
        }


    }

Thanks in advance

Edited by anand01

3
Contributors
5
Replies
6
Views
5 Years
Discussion Span
Last Post by maria99051
0

the first step would be to print the two values, for instance:
'firstPass ' + " == " + 'secondPass'

maybe in one of the two you have an upper case, which would mean they're not equal.

0

dear stultuske,
Thanks for your replay,
I tried even with numbers bu still the result false

0

This is a good idea, but note that you have to change the name in two places for this to work. You have to change it where you define the function, and then also change it where you call the function, so i.e.,

Pizza Express Vouchers

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.