What is the best non-framework (JSP/Servlet only) way to create a form such that it can:
- Prepopulate with default values / data loaded from a database
- Redisplay submitted values which fail validation
It seems fairly straight forward to do one or the other, but creating a form that supports both simultaneously is tricky.
For example using
${param.scheduledDate}
works great for re-displaying a date on validation failure, but can't easily be set programmatically on page load. Conversely,
${myBean.scheduledDate}
works great for displaying values loaded from a database, but can't re-display data on validation failure since the bean is using an object of type Date, not string.
A few things come to mind, but non really seem all that good:
- use an intermediate bean with just strings
- use a servlet filter to set parameters on page load