Transfer Sample


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

The Transfer enterprise bean models a transfer of funds. It moves a specified amount from one instance of the Account bean to another.

We access this enterprise bean from a Java servlet that creates the output HTML, from a Java servlet using a JSP file for output, and from a Java application.

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

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 Transfer sample has:

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

The second Transfer 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: To transfer funds, the Transfer enterprise bean requires at least two Accounts: one to transfer to and one to transfer from. You must first use the Account enterprise bean to create these accounts.


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 as 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.


An alternative - using a Java application:

You can also access enterprise beans from a Java application. The TransferApplication shows you how to access the same Transfer enterprise bean from a Java client application.