Tutorial‎ > ‎

Building Logic Tutorial

Rather than creating a completely new project, this tutorial starts by using Maven to acquire an existing, fully standard JSP / Hibernate web app, and illustrates how to add business logic.  The project can be completed in under 20 minutes.

This is Part I, where we create a project from Maven with Domain Objects, sample data, and a simple pre-supplied User Interface.  This should take approximately 5 minutes.  Completing this prepares you for Part II, where we add business logic to the project created here.

Use Maven to get project


These instructions presume you have JDK 6, a EE version of Eclipse (we use Indigo), with Maven installed.  It should work with other similarly configured IDEs.


Note: in the case of Eclipse, get Maven using Windows > Install Software > Indigo - http://download.eclipse.org/releases/indigo (it is not installed by default in the EE version).

This project also requires the WTP integration.  Ensure you have this (it can be obtained here).  You can verify it using Window > Install Software > What's Installed.

Download and unzip BusLogicTutorial

Download BusLogicTutorial.zip, and unpack it, creating a new folder called BusLogicTutorial.  It should look like this:

Create workspace

Create a new folder (e.g., BusLogicTutorialWS), and open Eclipse with this folder as your workspace.  Use the preferences to set defaults (fonts, etc.) as desired.

Import existing Maven Project

Right click on the left view, and Import > Import... > Maven > Existing Maven Project, and select the BusLogicTutorial folder created above:

On the ensuing dialog, select the BusLogicTutorial folder you created above.  It should then look like this:

This should complete without error.  See the callout text box at the top of this page for suggestions.

Create a Tomcat Server, and add the BusLogicTutorial Project

Select the Servers View, and right click to add a new Server:

Then select the folder where you have acquire a Tomcat server:

Verify Project Execution

Run http://localhost:8080/BusLogicTutorial/ (in some cases, you may have specified Tomcat to use port 9080):

Observe Changes are immediate

Notice there is no save button - all changes are saved after you finish editing a field.  This is just a simplification - you clearly don't have to do this in your application.

Project Creation Complete - Part 1

You now have a simple, but complete, JSP project, including a database schema and a web interface.

Well, maybe not that complete!  The business logic - see our cocktail napkin above - is totally missing.  This is first apparent from the loaded data (all the Customer balances are 0), and continues to be missing if you create, update or delete orders.

This is not a JSP issue - frameworks in general simply aren't built to address this element of your app.  The problem is, this is about half the app (even more as framework automation increases).

We are now ready to introduce business logic.

Val Huber,
Apr 25, 2012, 6:17 PM