I have worked as a developer in few enterprise applications mainly based in Spring Framework and Java EE (mainly EJB's); but not at all the layers (view layer is the least I have worked upon)
Considering a multi-layered application (Client layer, business layer, data layer etc) at which layer the data validation should happen?
I have heard of Bean validation API viz:JSR 303
; but the validations are performed in the Beans, that is server side (If I understood correct).
So in real applications where the validation should happen? Should some validation happen in client layer itself (for example if the view technology used is JSP, should the validation happen in JSP)? If so then what is the advantage of JSR 303
.
It also doesn't make sense to have the data travel from client to server to be rejected because of validations, I am not clear what is the proper approach on the validations.
Any explanation in understanding this is well appreciated.