In this lab, you will extend your work from the previous lab into the JSP architecture. In particular, you'll provide an interface which has two text fields in which the user enters the actor's first and last names, a radio button with which the user selects a store, and a submit button. When the user clicks submit, the two text fields are cleared, the radio button is left unchanged, and a table appears showing a list of titles of movies on the selected store's shelves which contain the selected actor. In addition to allowing the user to query your database, you can also provide you the ability to easily see more information about the movies, courtesy of The Internet Movie Database.
When I grade your labs, I will not just check that you have a correctly working application; I will also be looking to see that your application is well designed and documented. For this, I recommend that you follow the design process for the gened example I described in class. You also need to provide adequate documentation for the project, including in particular javadocs for your package.
If you wish, you may work in groups of two on the lab. (One group of three will be allowed, since there are an odd number of students in the class; however, if one, three, of five students want to work alone, then only groups of two will be allowed.) You should write the application from scratch, testing as you go. You should never be writing more than 10 or 20 lines of code before testing the code. Be sure you have a strategy for testing any code you write before you write it. If you need help with this, please ask.
As I said in class, you will need to put the
mysql.jar in the appropriate
directory. Assuming that you set up the
properly, issue the following command:
cp ~karl/public/270/mysql.jar ~/tomcat/common/libHaving done that, you should then look at that directory
As I said above, part of your grade will depend on how you organize of your project. I highly recommend that you borrow the structure that I used for the gened project I described in class. You can get that project directory by issuing the following command from the directory where you want the directory copied:
cp -r ~karl/public/270/jsp/gened .After doing this, look through these directories/files, make the application (described more completely below), test it out, and look at the documentation it creates. Before doing
make, you will need to have created the following directories:
~/webapps/gened ~/www-docs/gened ~/www-docs/gened/docs ~/www-docs/gened/docs/javadocsHaving done this, you should then set up a similar structure for application you will be writing. If you copied over and played with the files as described above, you will understand what I mean. I will refer to this directory as your JSP work directory.
As discussed in class, there is a GNUmakefile in the
gened/ directory. You carefully should look at this
file, since you will be using/modifying it in your project. To
install the application, go to the
gened/ directory and
issue the following command:
makeTo remove all backup files in the current directory, type:
make cleanTo generate the documentation, type:
.java files will be compiled into
.class files in a subdirectory of the root directory
~/webapps/WEB-INF/classes, where the path name is determined by
the package name you use. Your
therefore include this root directory if you want to test your Java classes
in isolation. If you use a
csh shell, you can put the
following in your
setenv KARL ~karl setenv CLASSPATH $HOME/webapps/WEB-INF/classes:$KARL/public/270/mysql.jar:.If you use
bash, put the following in your
export CLASSPATH=~/webapps/WEB-INF/classes:~karl/public/270/mysql.jar:.You'll need to either open a new shell or type
genedapplication you have copied over. Here is a brief description of the directories/files you should include:
GNUmakefile: The makefile which installs your application.
README: This includes brief documentation on your application. This is the first file I will look at and should paint a broad overview of your submission. In particular, it should contain a clear statement about what you have successfully tested and any bug reports. I should be able to replicate your tests.
docsdirectory: This should include a file
index.htmlas well as other html files that describe your application. Be creative. As one link, I would include a copy of the README file.
mockupdirectory: Include here the html mockups (prototypes) you write, which should be the basis for the jsp files you program.
JSPfile(s) containing your interface. You can probably get away with one jsp file, called, say,
gened, so you could, for example, call it
movies. This directory should include the following java files:
*Bean.javafiles: Java Bean(s) which holds the name of an actor and the store selected. You'll need at least three setters, which set the first name, last name, and store, three getters.
If you choose separate Beans to store the actor and the store, provide
toString() method which returns the full name of the
actor or the store name. If you combine them into one bean, while you
may want to make getters which return strings, you may also want a
toString() method to use for debugging.
Storeclass might be appropriate. You decide what you need.
QueryHandler.java: A Java class file which composes the SQL query and returns a list of movies. Your SQL query should be performed using a
PreparedStatement, since your interface will have text fields. The
PreparedStatementshould only be made once by the QueryHandler object rather than once for each query the object handles.
sqldirectory: include here the table definitions, the data files, and SQL queries you used.
jspfile, and what methods belong in auxiliary classes?
Lab4, now type:
submit program prints
out to confirm it seems to have submitted properly.