Bear Bibeault wrote:I think you are thinking of it from the wrong direction.
You are focusing on pushing the form data down into the business layer. Rather, think of it from the other direction. Imagine what business operation you are trying to model and create an API that is suitable. This API should be able to accept data from any source (e.g. the fact that it comes from a form submission in a web app should be moot).
Then you'll know how to write the servlet code to call that business API.
Frequently, if a large number of data items are needed to perform an operation, rather than having a method with a bazillion parameters, the data will be abstracted into a model class. For example, let's say the business operation is to create a new user. Rather than passing the individual properties (first name, last name, address and so on) a class that models a User will be defined and passed to the operation.
Michael Eller wrote:Do you mean...I can just gather the data and make the method call to the java class that handles the database from the doPost method of the servlet?
In other words, write your business layer as if it could be used from any type of application: web, command line, Swing, etc.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |