Trying to do front-end validation on an HTML input instead of throwing an exception in the Java back-end.
if ((the_number >> 0) != the_number) {
// overflow...
}
You still need a server-side check because the client-side may turn off Javascript, etc.