I would say that the cleanest way to do your validation is to use a validation framework. I know it requires a bit of reading but It will help in the long run.
Two such packages I suggest are the one from the SpringFramework http://static.springframew
Once you get used to them you end up saving time not writing the same validation code over and over again
Main Topics
Browse All Topics





by: KuldeepchaturvediPosted on 2007-12-06 at 09:45:12ID: 20421519
1. Degree of Imbalance:<input name="DegImb" type="text">, must be an integer value
mb");
arse(reque st.getPara mater("Beg Date");
2. Min. Flows Per Hour: <input name="TotalFlowImb" type="text">, must be an integer value
3. # of Results: <input type="text" name="Num_Results">, must be an integer value
4. Begin Date <input type="text" size="10" maxlength="20" name= "BegDate"> must be a date value
5. End Date <input type="text" size="10" maxlength="20" name="EndDate" > must be a date value
6. begtime <select name="begtime">, must be time value
7. <select name="endtime">, must be a time value
in your action url servlet.
try{
String degImp = request.getParameter("DegI
int degImpint = Integer.parseInt(degImp);
// Same code for your other two variables.
Date begDate = DateFormat.getInstance().p
//same code for your second date.
}
Catch ( Exception e)
{
//validation failed.
}