I want to create a JSP Form page on Tomcat with a form that has about 10 input entries where the form will validate all 10 fields and show validation errors on the same page as the original form JSP page.
For example, if someone has a blank entry on the Firstname field then it will show this message in red next to the field: First Name is required.
If the data passes the validations it will populate an Oracle database. Please advise any suggestions on how I should do this. I was thinking of submitting the fields to a Controller servlet then use the Enumeration class to get all field values where I would check for blanks. I assume if I use a bean and have a getter and setter method for each field I would then have 20 methods (10 setter and 10 getter methods) in the bean class.
I dont have Struts due to certain restrictions and need to know the best way to do this. Can anyone give me ideas or examples of how do to this?
Hi oaklander,
Welcome to TSDN.
**Server side validations are much safer, but consume more resources and take time.
Client side validations are less resource intensive, and gives a good user experience.
So you need to do some trade offs while picking up the approach.
Disadvantages of server side validation:-
1. resource intensive. You need to reach the server again and again(if validation fails).
2. Time consuming. If network is slow then user could get frustrated.
Disadvantages of client side validation:-
1. if javascript is disabled on the client machine, then no validation will occur.
2. if someone wishing to corrupt your data, he/she can by-pass your javascript validations (search google to know how it can be done).
So keeping in mind these points when you design your application.
One solution is do general validations which are not critical (eg:- if a field is empty) on client side and do critical validations on server side.
other way is you could use AJAX techniques, so that user can do his work and validation requests go to the server asynchronously.