Check input data from a .jsp form

Hey,

I have created a pretty standard registration form in a jsp, but I'm not sure of the best way to check the data that has been entered. I'm want the program to check as the user inputs the values. So if the two password inputs do not match, for example, a string would be shown to alert the user without them having to submit the form.

I know this is possible with JavaScript, but what would be the best way to do this with Java?