Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

Build an Ajax-enabled application using the Google Web Toolkit and Apache Geronimo, Part 2: Integrate your Ajax apps with a back-end MySQL database using a servlet

Michael Galpin, Developer, Adomo, Inc.
Michael Galpin's photo
Michael Galpin has been developing Java software professionally since 1998. He holds a degree in mathematics from the California Institute of Technology and currently works at Adomo, Inc.

Summary:  In the first part of this tutorial series, you learned how to use the Google Web Toolkit (GWT) to rapidly build an Asynchronous JavaScript + XML (Ajax)-enabled Web application and deploy it to Apache Geronimo. In this installment, Part 2 of the two-part series, you add more functionality to the application that you built in the first tutorial. Take advantage of Geronimo to add new features to the application by managing access to a back-end database. Then use GWT to add more dynamic functionality and easy integration with the new features that the service provides. Also, take a look at some of the dynamic HTML (DHTML) features of GWT and using native JavaScript within a GWT application.

View more content in this series

Date:  21 May 2007
Level:  Intermediate PDF:  A4 and Letter (1528 KB | 40 pages)Get Adobe® Reader®

Activity:  10120 views
Comments:  

Before you start

About this series

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.

About this tutorial

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.

Check out the Ajax Resource Center, your one-stop shop for information on the Ajax programming model, including articles and tutorials, discussion forums, blogs, wikis, events, and news. If it's happening, it's covered here.

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.

Prerequisites

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.

System requirements

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.

1 of 8 | Next

Comments



Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Open source, Web development, WebSphere
ArticleID=223485
TutorialTitle=Build an Ajax-enabled application using the Google Web Toolkit and Apache Geronimo, Part 2: Integrate your Ajax apps with a back-end MySQL database using a servlet
publish-date=05212007
author1-email=mike.sr@gmail.com
author1-email-cc=

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere).

My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Try IBM PureSystems. No charge.