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.
mysql.jar file
As I said in class, you will need to put the
mysql.jar in the appropriate tomcat
directory. Assuming that you set up the tomcat stuff
properly, issue the following command:
cp ~karl/public/270/mysql.jar ~/tomcat/common/lib
Having 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/javadocs
Having 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:
make
To remove all backup files in the current directory, type:
make clean
To generate the documentation, type:
make docs
Note that .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 CLASSPATH should
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 .cshrc:
setenv KARL ~karl
setenv CLASSPATH $HOME/webapps/WEB-INF/classes:$KARL/public/270/mysql.jar:.
If you use bash, put the
following in your .bashrc
export CLASSPATH=~/webapps/WEB-INF/classes:~karl/public/270/mysql.jar:.
You'll need to either open a new shell or type source
.cshrc (or ConflictBean.class in package
gened, I would type;
java gened.ConflictBean
Note that you need to include the whole package name and that you
don't end with the .class extension. Feel free to make
your package names short to save typing. Or you can save typing by
setting a shell variable to be the package name: If the package were
edu.gustavus.karl.gened, then in bash,
type:
gened=edu.gustavus.karl.gened
In csh, type:
set gened=edu.gustavus.karl.gened
When tomcat has troubles compiling your .jsp files, the error messages printed in your web browser can be helpful, and the line numbers refer to lines in tomcat's java file constructed from your .jsp file; it will be in a subdirectory of
~/tomcat/work/Catalina/localhost/
As you debug your .jsp files, don't forget that output
sent by anything to System.out (whether it be by your
.jsp or a .java program) goes to
~/tomcat/logs/catalina.out. David Wolfe will often type
the following in a shell so that all output to
catalina.out immediately appears in the shell window:
tail -f ~/tomcat/logs/catalina.out &
gened application 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.
docs directory: This should include
a file index.html as well as other html files that
describe your application. Be creative. As one link, I would include
a copy of the README file.
mockup directory: Include here the
html mockups (prototypes) you write, which should be the basis for the
jsp files you program.
jsp directory: The JSP
file(s) containing your interface. You can probably get away with one
jsp file, called, say, findActor.jsp.
gened, so you could, for example, call
it movies. This directory should include the following
java files:
*Bean.java files: 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
a 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.
Movie or a Store class 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 PreparedStatement
should only be made once by the QueryHandler object rather than once
for each query the object handles.
sql directory: include here the
table definitions, the data files, and SQL queries you used.
jsp file, and what methods belong in auxiliary
classes?
Lab4, now type:
~karl/public/270/submit Lab4
submit program prints
out to confirm it seems to have submitted properly.