dharan dharan - 3 months ago 10
Java Question

How to check two strings are equal in JSP?

how to check whether these two strings are equal in Java using if...else block.

String passw1=(String)request.getParameter("pass");
System.out.println("value of passw1"+passw1);
String passw2=(String)request.getParameter("pass1");
System.out.println("value of passw1"+passw2);
//String a=passw1;//String b=passw2;
if(passw1.equals(passw2))
{
out.println("Password matches");

Answer

Scriplet accept java code so its simple like this

    <% 
 if(request.getParameter("pass")!=null && request.getParameter("pass1")!=null){
       String passw1=(String)request.getParameter("pass");
       String passw2=(String)request.getParameter("pass1");
       if(passw1.equals(passw2)){
         //equal
       }
}
   %>

Is it ok or you try to explain other thing?