Account Sample


The Account entity bean, along with the Transfer session bean, provides a simple banking application.

The Account enterprise bean is a model of a savings or checking bank account. Each account has an unique ID, an account type, and a balance.

We show you how to access this enterprise bean from a Java servlet that creates the output HTML and from a Java servlet using a JSP file for output.

Run the servlet that creates HTML
Run the servlet that uses a JSP

Show the source files


Reminder: Before you can run any of the sample enterprise beans, you must deploy them.


How this sample works:

The first sample has:

  • An input form to enter data
  • A Java servlet, CreateAccount, that reads the input data, accesses the Account enterprise bean, and returns the formatted HTML
  • An enterprise bean, Account, that reads and writes the persistent data

The second Account sample is similar except its Java servlet does not format the HTML. Instead, this sample uses a JavaServer Page that contains HTML tags for the static output and JSP tags for the variable output.

Note: These samples use a DB2 database to store their persistent data.


How to use this sample:

The Transfer and Account enterprise beans can be the starting point for any application that deals with accounts and amounts. You could modify them to track and transfer items, such inventory, as well as monetary units.

Be sure to see how they were adapted to handle vacation and sick leave accounts at the YourCo Employee Center.