servlet code to update password?

Create a servlet page which helps the user to update his password. The user should give the username,old password,new password,confirm password. The updation is applicable only for valid users.then Store it into a table.