aspose file tools*
The moose likes Servlets and the fly likes Best way to do form input ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Best way to do form input ?" Watch "Best way to do form input ?" New topic
Author

Best way to do form input ?

Phil Chuang
Ranch Hand

Joined: Feb 15, 2003
Posts: 251
I've done around 3 different web applications now, and all 3 have handled JSP form input & field validation in different ways - so the question I pose to you all is, what is the best way?
Given these constraints:
1) clean & simple design
2) easy linking between the JSP form fields and the bean fields (loading)
3) easy way to do validation
I would guess that some degree of reflection would be used to automate the field processing.
So here's my current take on things:
Common JavaBean, but with the addition of a set of validation methods (get/set/validate) that take in String input and validate it against the field type. I'm planning on naming the fields in the JSP exactly as the field name in the bean, although that might run into problems if the input uses more than one bean and they have the same fieldnames. Once the form is submitted, go through all the input parameters calling the validate & set methods for the appropriate fields.
how's that sound?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Best way to do form input ?
 
Similar Threads
mutiple record validate
Controlling Struts Validation Dynamically
strut validation frame work issue
JSF clear fields on validation errors
use bean instance in servlet