How we can validate the our jsp form before storing the data in database
Indeed - "by checking that the input is valid".
Andrzej Doyle
2009-02-05 12:13:21
Marko, while your answer may be 100% correct, I'd edit to add a link to some site on the web with more information... would be a lot more helpful to the asker, dontcha think? =8-)
Yuval
2009-02-05 12:20:44
Given the question itself and info provided in it, this answer is all I can offer :)
Dev er dev
2009-02-05 12:42:07
+1
A:
Depends on the framework you are using. If you are developing bare Servlets - you can build your own validator framework (each entity should have a separate class holding validation code for that entity)
If you are using some framework (Struts, Spring, etc), you should check their documentation.
miceuz
2009-02-05 12:11:34
A:
Depending on the validation needed, a better approach might be to validate the data on the client (perhaps using Javascript). It'll save a server-client trip and will provide users with immediate feedback.
Zabbala
2009-02-05 13:48:44
This requires server-side validation as well. Client-side is an optional extra; you need to validate at your application's entry point. Otherwise anyone malicious could just disable Javascript etc etc.
Robert Grant
2009-02-05 13:52:27
I agree. But if the validation needed is say: 'username should be 8 characters long or checking the validity of a date entered', a quick JS function could provide immediate feedback. This should not replace any validation done on the server before the interaction with the database.
Zabbala
2009-02-05 14:12:14