CPSC 371 Lab, 7 November 2003
Database Work

The most important thing that you should be doing at this time is working on your term project. Before you start the real design work, you should do the Use Case analysis and database design, as was covered in Chapter 6 of Struts Kick Start. By the next lab, you should definitely have your database set up, and you should have some work done on your main page. (And you can't really do this until you have your Use Cases.)

Your project will use several database tables, in addition to the user tables you made in a previous lab. You should keep the CREATE TABLE commands for those tables in a file. This will make it easier to create the table in the first place, and it will make it possible to recreate the tables if necessary.

You can use whatever extra time you have today in lab to work on your database. (Or, you could work on other aspects of your project if you prefer.) It would be a good idea for you to discuss your plans with me as you work.

Next Friday, you should turn in a copy of the CREATE TABLE commands for your data base, along with a short English description of what you will do with the data in the tables. This will be graded for a small number of points.


WAR Files

Web applications are distributed in ".war" files. These files have the same format as jar files and can be created with the same jar command-line tool. A war files contains one entire Web application; that is, it contains everything from the application's directory. If you obtain a war file, you can simply place it in Tomcat's webapps folder and restart the Tomcat server. Tomcat will automatically unpack the war file, and the new application will be available. The name of the new application will be the same as the name of the war file, with the ".war" extension removed.

You will find a file named dbtags.war in the /home/cs371 directory. Copy this to your server's webapps directory, and restart Tomcat. You should be able to access the new application at a URL of the form http://cslab8.hws.edu:8080/dbtags. That's all there is to it (unless the application uses a database -- in that case, the database must also be set up in a separate operation to make the application functional).

Suppose that you want to create a war file of your application. Just change into the application directory. (It's important that you be in the application's directory for this.) Then give the command

              jar  cf  appname.war  *

replacing appname with the name of your application. (The war file will be created, inside the application directory. You want to move it somewhere else, because it's not part of your application.) I might ask you to submit a war file of your application at the end of the term.

By the way, when a war file is unpacked, the name of the application comes from the name of the file, not from the original name of the application from which the war file was created. So you can safely try to unpacking with your own war file if you want -- just give it a different name from the original application.


Some DataBase Tags

The application in the sample dbtags.war file contains a simple tag library for working with a database. The main page of the application describes the tag library. (You can also read the documentation at http://math.hws.edu/eck/cs371/dbtags.html".) You will also find some examples of using the tags. At the moment, the tags still need a lot of testing; a new version will be released with corrections if necessary.

You should consider using this taglib for database access in your project. You only need to copy xdb.tld to your the WEB-INF directory in your own application and copy xdb.jar to your own lib directory. We might look at this taglib further in class.


David Eck