This week's book giveaway is in the Java in General forum. We're giving away four copies of Helidon Revealed: A Practical Guide to Oracle’s Microservices Framework and have Michael Redlich on-line! See this thread for details.
A user cannot enter null. I assume you mean leave it blank?
In any case, are you asking about client-side validation? If so, you'd use JavaScript.
If server-side, use Java in the servlet (not JSP) to which you submit the form. You should always validate on the server even if you perform client-side validation.