Before you start
This tutorial series is for Java™ Platform, Enterprise Edition (Java EE) developers who want to learn more about the Spring Framework and how to make use of its powerful features on the Apache Geronimo application server.
This six-part tutorial series introduces you to the Spring Framework and how it fits in with Geronimo. You began by examining the different Spring Framework methodologies and how each works with the Geronimo server. You'll develop and deploy a personal phonebook application throughout the series. The application will include the following functionality:
- Showing the phonebook
- Showing details of each entry
- Adding new entries to the phonebook
- Editing, modifying, and deleting an entry
- Adding more details to the entry, such as primary e-mail addresses
Part 1 introduces each module of the Spring Framework and how each relates to the development of Java EE applications on the Geronimo application server. It also explains the methodologies that the Spring Framework is based on.
Part 2 covers how to build your first bare-bones application using the Spring Framework on Geronimo.
Part 3 shows how to extend the Geronimo application from Part 2 by adding Java Database Connectivity (JDBC) support via the Derby database. In it, you see how to integrate Object Relational Mapping (ORM) to your application using iBATIS.
Part 4 introduces Spring AOP and the Spring Web Framework. With the Spring AOP, any object managed by the Spring Framework can become aspect oriented, and this tutorial relies on the declarative transaction management services provided via the Spring AOP.
Part 5 examines Spring MVC and gets you started with the Spring MVC by introducing its MVC framework and Web views.
This final installment, Part 6, shows you how to use JSP, Velocity, Tiles, and PDF export using the Spring Framework. You get to experiment with various Web views built into the Spring MVC.
As mentioned, Part 5 of this tutorial series provides a thorough introduction to the Spring MVC module. You learned about different controllers offered by the Spring MVC — the C from MVC. This tutorial examines different view technologies — the V from MVC.
One of the biggest challenges that Web application developers face is creating an adaptable design. Making your views component flexible is particularly challenging. Because Spring's support for views is so robust, this challenge is more manageable. The use of JSPs, Tiles, Velocity, and PDF export in this tutorial is designed to demonstrate how the Spring MVC API makes this possible.
JSPs and Velocity are two complementary view technologies. You can create views using either one, each with its own set of advantages and disadvantages. This tutorial demonstrates how easy it is to replace one with the other in the sample Phonebook application.
You begin by reviewing JSP support in Spring MVC and then looking at Tiles, a very good templating engine for view layout management. Tiles makes it easy to manage your Web page layout, and Spring has built-in support for Tiles. You'll make use of these classes to change the Web layout of the Phonebook application.
Next you'll replace the use of JSPs by using views defined with the Velocity templating engine. Velocity makes it easy to access Java objects in your views without complex definitions and Java constructs, such as Try Catch loops.
Finally, you get a look at rendering the Phonebook application's home page to be displayed as a PDF file. Spring takes care of all the cumbersome and complex code and logic needed to create a PDF. It gives you a clean API to work on the content, without confusing you with PDF details.
To follow along with this tutorial you should have a basic understanding of:
- Object-oriented programming
- Java Platform, Enterprise Edition (Java EE) terminology
- SQL statements
- XML semantics
- JSP tags, tag libraries, and tag library descriptors
An understanding of MVC is a plus, and a working knowledge of Velocity is also highly advantageous, but isn't required.
You need the following tools to follow along:
- The Spring Framework V1.2.8 — You'll be using the compressed file with all dependencies.
- Apache Geronimo V1.1 — Geronimo is a Java 2 Platform, Enterprise Edition (J2EE)-certified application server from Apache.
- Apache Derby database — This tutorial uses Derby, which is an open source lightweight database. Derby is embedded within Geronimo 1.1, so no separate installations are required.
- Velocity JAR files — You'll need the JAR files from the Velocity Template engine. You can either copy them form your Spring Framework installation or download it from the Velocity site.
- iText — This is the PDF library used to generate PDFs on the fly. Spring uses this library to generate PDFs, and it's part of the Spring Framework.
- Struts — This is the Tiles support from Spring that's dependent on the Struts API. You need the main struts.jar file from this API, which can be found in the Spring Framework.
- Commons library JAR files needed by Spring Tiles support — You need commons-digester.jar, commons-collection.jar, and commons-beanutils.jar. These all come with the Spring Framework installation, so just copy them into your development environment.
- Standard taglibs API — Because you'll be using JSP Standard Tag Library (JSTL) tags in your JSPs, you need the JAR files from this compressed file.
- Standard JSTL library — The current release is 1.1.2.
- Apache Ant — Make sure Ant is configured properly and that its /bin directory is in your Path system variable.
- Java 1.4.2 — Make sure Java is installed and running on your system.
Install and configure the software
This section contains instructions for installing and configuring the software required to develop, deploy, and run the example application.
- Spring Framework and Geronimo installation: For the sample code to run, you need a working installation of both Geronimo and the Spring Framework. (Refer to Part 2 in this series for installation instructions.)
-
JAR files needed to resolve Tiles dependencies: The following JAR files are needed by Tiles support in Spring:
- Struts.jar — <SPRING_HOME>\lib\struts
- Commons-digester.jar — <SPRING_HOME>\lib\jakarta-commons
- Commons-collection-3.2.jar — <SPRING_HOME>\lib\jakarta-commons
- Commons-beanutils.jar — <SPRING_HOME>\lib\jakarta-commons
All of these JAR files come bundled with the Spring Framework installation package. You can find them in the directories indicated in the above list, next to the .jar file name. Make sure to copy all of these JAR files into the <WORKSPACE>/phonebook/lib directory. - JAR files needed to resolve Velocity dependencies: The sample Phonebook application needs to include velocity-1.4.jar to work with Velocity. Velocity also needs the commons-collections.jar you copied for Tiles integration. The Velocity .jar file can be found in the Spring installation directory in <SPRING_HOME>\lib\velocity folder. Make sure to copy this into your <WORKSPACE>/phonebook/lib directory.
- JAR files needed to resolve PDF dependencies: Spring's PDF support API makes use of iText PDF library, so you need that for creating PDFs for your application. Like the other JAR files, this one also comes prepackaged with the Spring installation. You can find the itext-1.3.jar file in <SPRING_HOME>\lib\itext. Copy this in the lib directory as well.
- Installing Standard Taglibs from Apache and the Spring taglib: You'll use the JSPs defined in Part 5 of this tutorial series and extend your application using them, so you need to install JSTL libraries. (Refer to the installation instructions in Part 5 of this series.)
- Data model definition and database setup for your application: You'll use the same Derby database that you created in other parts of this tutorial series. The data model is also the same. If you created the database and tables in Part 3, 4, or 5, then you should be all set. If not, please follow instructions from Part 3 to take care of that first.

