Once the user types in the pwd and submits the form, the only way you can encrypt is by having a javascript function do it - but then users can quite easily view the html source and hence your encryption algorithm.
Rather than ecryption, you can use SSL connection for pwd form submission. If you are worried that the password will be visible in tthe url, all password forms should use the post method. You should use a session mechanism so that the password is transmitted just once in the session and after that its the session cookie that identifies the user. Finally you can encrypt the password before storing it in the db - use something like SHA -or better google for password encryption + java.
ram.