You have all the information on the server -- including the nature of the error that your code just detected. It's an easy matter to use JSP technology to format the HTML as appropriate. You can conditionally create an error message on the page, and fill in the form fields with the previous submitted value for a parameter.
For example, assuming that the JSP is being generated in the same request as the form submission (not always true):
Conditional markup is easy with the JSTL <c:if> action:
[ June 17, 2007: Message edited by: Bear Bibeault ]