<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@page import="java.util.Date"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.text.ParseException"%>
<%!
private Date parseDate(String dateValue)
{
Date returnDate = null;
try
{
// this is not the most efficient of methods, and try...catch
// statements ideally should not be used as business exception
// processing...
SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
returnDate = dateFormat.parse(dateValue);
if ("process".equals(request.getParameter("action")))
{
// verify the date
Date birthDate = parseDate(request.getParameter("birthdate"));
if (birthDate == null)
{
// display the error messages...
out.write("<p class=\"error\">lease enter a valid date.</p>");
} else {
// display the nice messages...
}