I’m using a three-page process in my web application to deal with data input:
first page is the formsecond page is the processing of the form and performing the associated actionsthird page is the success/fail feedback pageMy question is concerning the second page of this process: form processing and action.
What is the best way to process a form and act on its information? There are several ways that I can do this work: through
java beans,
EJB, taglib, etc, but what’s the best way?
Java Bean: For example, I could do it through a java bean. If I had a form with two text entry fields, something like this:
and a java bean that looked something like this:
then my form processing page could look something like this:
TagLib using property names: I could also do the work through a tag library, passing the names of the form’s fields to the tag’s attributes. Thus, my second page would look something like this:
In this example, the tag library would retrieve the values of the named properties from the request object and perform the required actions.
TagLib using property values: Another possibility is to use a tag library, passing the values of the form’s fields to the tag’s attributes. Thus, my second page would look something like this:
Here, the tag processPerson would then use the values passed directly to it and perform the required actions.
TagLib in conjunction with a java bean: One final possibility is to use a java bean to get the form’s values, and to use a tag lib to process the work. Here, I’d be separating the two tasks of form processing and work to two separate objects. Thus, my second page would look something like this:
Here, the "person" bean would populate itself based on the form, and then the "processPerson" would get that bean from the request object and perform the work using that bean as data.
So what’s the best way to perform this very common action? I’m slightly preferential to a java bean as it’s reusable in a non-web situation whereas tag libraries are designed for web use only.
What are your thoughts and why?
(ps: please excuse my formatting, I'm playing around with the UBB code)