A lot more factorization

Make all input fields etc share the same name, factorize Java code and
JavaScript code accordingly.