
i have two jsps in one jsp i give one password and confirm password, in another jsp i want change my password compare with 1st jsp how to write code please give me answer?

Here is a jsp code that change the password.
1)change.jsp:
<html> <form action="changePassword.jsp" method="post"> <table> <tr><td>Current Password</td><td><input type="password" name="current" ></td></tr> <tr><td>New Password</td><td><input type="password" name="new"></td></tr> <tr><td>Confirm Password</td><td><input type="password" name="confirm"></td></tr> <tr><td><input type="submit" value="Change Password"></td></tr> </table> </form> </html>
2)changePassword.jsp
<%@page import="java.sql.*"%>
<%@page import="java.io.*"%>
<%
String currentPassword=request.getParameter("current");
String Newpass=request.getParameter("new");
String conpass=request.getParameter("confirm");
String connectionURL = "jdbc:mysql://localhost:3306/test";
Connection con=null;
String pass="";
int id=0;
try{
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection(connectionURL, "root", "root");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select * from login where password='"+currentPassword+"'");
while(rs.next()){
id=rs.getInt(1);
pass=rs.getString(3);
}
System.out.println(id+ " "+pass);
if(pass.equals(currentPassword)){
Statement st1=con.createStatement();
int i=st1.executeUpdate("update login set password='"+Newpass+"' where id='"+id+"'");
out.println("Password changed successfully");
st1.close();
con.close();
}
else{
out.println("Invalid Current Password");
}
}
catch(Exception e){
out.println(e);
}
%>