Programming Assignment 1

You will learn in this assignment how to package applications for deployment into an application server, how to write JSPs and servlets, and how to communicate with databases from your program. For this assignment, we will be using the following software:

  • Install JBoss application server.
  • Install MySQL database server.
  • Install the MySql JDBC driver. Make sure it's in your classpath.
  • A note about setting classpaths .

    Begin Update

    (1/18/2006)

  • The deliverables for this assignment have changed. You will now submit a zip file containing the .ear archive and your source code.

    (1/16/2006)

  • The database must be accessible using an anonymous account.
  • All the software required should install just fine on Windows XP.

    (1/11/2006)

  • You will not need to use university Oracle accounts for any assignments. I am assuming you can setup your own MySql server. This reduces reliance on university infrastructure.
  • Name are cases-sensitive, for instance, the table name 'Accounts'. 'accounts' will not work.
  • Time spent understanding the structure of .ear archives, how applications are deployed in JBoss, and Ant is time well spent. The rest of the assignment should be fairly straighforward.

    I suggest the following course of action to make the assignment more manageable:

    1. Write a simple servlet of the 'Hello World' flavor. Write the Ant script to deploy into JBoss. Test by accessing the servlet through a browser.
    2. Write a standalone JDBC application to do as the problem states.
    3. Marry the two above.

    End Update

    Problem

    Write a JSP/servlet for a simple banking interface for Bank Zarro. It should have the following functionality:
  • Creation of a new account,
  • Crediting money into an account, and
  • Debiting money from an existing account. See my example implementation. Note that I have overloaded creation with depositing. Your interface need not be like mine---it is just for reference---as long as it's intuitive. Your program should take care of common errors like entering invalid values and doing invalid operations.

    Systems Requirements

    To store account information, you must use a database in the backend and communicate with it over JDBC. Install and use MySql (preferably). The database must conform to the following schema:
  • The name of the database must be 'test_csc513pa1'
  • The name of the table must be 'Accounts'
  • It must have two columns, namely, 'id' and 'amount'.
  • No two rows can have the same value of 'id'.

    The above schema may be implemented outside the program before running the program by using the mysql command-line client. Your program then just queries the table, and inserts and modifies rows.

    Don't forget to load the MySql jdbc driver in your program! In your program, in the URL you will specify to the database server's location, use 'localhost' instead of a dns name or IP. More

    Deliverables

    Deliver the application as a .ear archive. The archive must conform to the following:
  • The name of the archive must be < your-unity-id> .ear.
  • The file application.xml must be such that I can access your application using the URL http://< server_name >:8080/< your-unity-id>. See mine. See also.

    If your program conforms to the above, then there will be no need for a README file. Your program should work out of the box.

    Ant is a great tool for building and packaging java applications. It is similar to the GNU make utility---consider Ant its Java/XML avatar. All I do is edit my source files and invoke ant to build, package and deploy the .ear into JBoss. I highly recommend using it to build your .ear archive. See my build file. Study it carefully. It yields useful clues about the structure of a web application.

    This is more or less the assignment. Further fine-tuning may be done in the next couple of days. Be sure to check out this page.