So you are getting a NullPointerException, so it is printing null in browser.
Empty field validations should be done on form submit, not onkeyup.
Empty field validation on server side is a good practice, but first level validation should be in client side.
Use JQuery for AJAX, it will make your life very simple.
And try to debug by printing values in Java/debugging if you are using Eclipse/other IDE.