i need help in jsp and servlet .i have one jsp page in that page i have problem in servlet and jsp page .
i have one jsp page in the that page i have "date ,Ph,metrerial etc r fields ... so, when i enter any date then its releted record will be fill up .
DATE: 11/2/2003
fe:12
ph:23
Meterial:25
like that ...
but i have problem that when i enter 11/2/2003 date then it display all records which r in db. when i enter another date then its releted records will be filled so, pls what should i do?
How can we built date validation servlet?
On your servlet, you can use something similar to validate the date passed:
protected void doPost(HttpServletRequest request, HttpServletResponse response) {
String date = request.getParameter("date");
if (date == null) || date.equals("")) {
throw ServletException("No date parameter specified");
}
try {
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
dateFormat.parse(date);
} catch (ParseException e) {
throw new IllegalArgumentException("Cannot parse date: " + date);
}
// rest of your servlet code
}
In addition, use client-side scripting (e.g. JavaScript) on your JSP pages to do validation before form submission.
dentistry
No comments:
Post a Comment