Before you start
Ajax-enabled Web applications have become incredibly popular recently. Ajax makes Web applications behave a lot like desktop applications. They offer greater interactivity and functionality than the previous generation of Web applications. And Geronimo provides the perfect platform for building Ajax-enabled Web applications.
However, building Ajax-enabled Web applications is more difficult than building traditional Web applications. It involves lots of JavaScript and Dynamic HTML (DHTML) development. Quirks among different browsers—and even different versions of the same browser—further complicate things. The GWT is one of many Ajax frameworks that makes your job easier by using a novel approach that lets you write all of your code in the Java language and generates all the JavaScript for you. The two tutorials in this series cover the following topics:
- Part 1 focused on getting started with GWT and creating a simple Ajax-enabled Web application for getting stock quotes.
- Part 2, this installment, shows you how to make the stock quotes application more sophisticated and transform it into a stock portfolio application using both GWT and Geronimo.
In the first part of the tutorial series, you built an Ajax-enabled Web application. Now you're going to expand on this application and use more enterprise features, like database access. See how GWT lets you use Ajax to make it easy to send messages to a server, and how Geronimo makes it easy for your server-side application to update a database asynchronously.
In this tutorial, you turn a stock application into a portfolio management application that:
- Allows your users to get quotes on multiple stocks, thus building a portfolio.
- Lets users save their portfolios by giving themselves user names.
- Adds the stock to users' portfolios each time they ask for a quote.
- Uses Geronimo to create a pool of connections to that database and then uses JDBC to read and write to the database.
- Saves the users' names and the stocks in their portfolios in a relational database.
This tutorial is about building a Java Web application, but you only need to understand the basics of Java servlets. GWT leverages many ideas common to other technologies, such as layout management, event systems, and remote procedural calls (RPCs), so prior exposure to these ideas makes it easy to master GWT. The tutorial uses SQL and Java Database Connectivity to work with a relational database, so some familiarity with these tools is helpful.
You need the following software to set up your development environment before getting started:
- Geronimo 2.0 with Tomcat — The sample Web application in this tutorial was built using Geronimo with Tomcat, but it should also work with Geronimo with Jetty, because everything is standard Java Platform, Enterprise Edition (Java EE). This tutorial uses Geronimo 2.0 (M3) but should work with older versions of Geronimo as well.
- Java 5 or Java 6 — The sample Web application uses generics and annotations. It was developed using Java 6, but also tested against Java 5.
- Apache Jakarta implementation of JSTL 1.1 — Geronimo 1.1 is a certified J2EE 1.4 implementation, so you need to use JSTL 1.1.
- Google Web Toolkit — This tutorial is all about the GWT; download GWT 1.3.3 for this tutorial.
- Eclipse — The sample Web application is built using Eclipse, as you'll see from the screen captures. GWT includes a convenient command-line tool for creating a skeleton Eclipse project. It's not hard to build GWT applications without Eclipse, but Eclipse provides a great debugger to debug your GWT application.
- MySQL 5.0 — The sample application uses MySQL as its database. One of the great things about Enterprise Java and Geronimo is that you can easily switch out and use a different database. A great alternative is Apache Derby, which comes embedded in Geronimo. There were some bugs with Geronimo using embedded Derby as part of the 2.0 development, so this tutorial uses an external database.
For instructions on downloading and installing GWT, see Part 1 of this series.


