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

could any one help me

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.

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

add a print that shows both the values you're comparing, maybe the values aren't what you think they are.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.