Q:

Date or String declaration in a javabean

Should I declare an attribute in a javabean that holds a date value a user types in on an HTML form as a String or Date?  
I feel I should declare as a Date, however, since I do server validation on all form data, if the date doesn't validate, when I pass the form bean back to the jsp view for correcting, I lose the date value that the user tried to type in.  
If I declare as a String, if the date doesn't validate, I'm able to set the string value in the bean and pass the bean back to the view and the user can see what they incorrectly typed.  
But with a String declaration for Date inputs I forsee problems down the road with my DAO.  I want to be able to use a DAO utility which generates a prepare statement using setObject.
In my html form I request dates to be mm/dd/yyyy and in DAO i'm using Oracle Date.  I can not use hibernate or such, since this is a corporate intranet.
What is the best practice "pattern" I should be following??  

A:

Just store it as Date in the model. You can make use of conditional operator in EL to display the submitted value instead of the model value whenever the model value is absent.
<input name="date" value="${empty bean.date ? fn:escapeXml(param.date) : bean.date}" />

The JSTL fn:escapeXml() is just there to avoid XSS attacks.
To get a step further, you could add an extra layer with a Map<String, Object> params which contains either the submitted value or the final/validated value depending on the validation outcome.
<input name="date" value="${fn:escapeXml(bean.params.date)}" />

