In this lab, you will extend your work from the previous lab into a 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 you to query your database, this will also provide you the ability to easily see more information about the movies, courtesy of The Internet Movie Database.
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.
You may wish to refer to the gened application which I
went over in class. It's found in
~wolfe/public/270/jspapps/gened/.
I highly recommend keeping on your source files in one directory, and utilizing a Makefile to copy and/or compile files to the appropriate destinations. For instance, you could place all your files in
~/mcs270/actorFinder/
As discussed in class, a very simple GNUmakefile is found in the
gened/ directory. It should function so long as you have
at least one jsp file and one compilable
.java file. Once you've placed the GNUmakefile in your
source directory, if you want to install all .jsp files, and compile
any .java files which you have edited since the last compile, type:
makeTo remove all backup files in the currect directory, type:
make clean
.class files
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 WOLFE ~wolfe setenv CLASSPATH $HOME/webapps/WEB-INF/classes:$WOLFE/public/270/mysql.jar:.If you use
bash, put the
following in your .bashrc
export CLASSPATH=~/webapps/WEB-INF/classes:~wolfe/public/270/mysql.jar:.You'll need to either open a new shell or type
source
.cshrc (or MyProg.class in package
edu.gustavus.wolfe.gened, I would type;
java edu.gustavus.wolfe.gened.MyProgNote 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: In
bash, type
gened=edu.gustavus.wolfe.genedIn csh,
set gened=edu.gustavus.wolfe.genedIn either case, you can now type,
java $gened.MyClass
tomcat installation, that
.jar files need to be in an appropriate lib
directory for tomcat to see them. Your QueryHandler will require
the class com.mysql.jdbc.Driver which is found in
mysql.jar. Copy this jar file to your
WEB-INF/lib directory:
cp ~wolfe/public/270/mysql.jar ~/webapps/WEB-INF/lib/
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/Standalone/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.
I 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 &
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.
findactor.jsp: The JSP
file containing the interface.
*Bean.java:
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.
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.
query.sql: A sample SQL query which
is hardwired with a specific actor of your choosing.
GNUmakefile: A makefile which
installs your application.
jsp file, and what methods belong in auxilary
classes?
Lab4, now type:
~wolfe/public/270/submit Lab4
submit program prints
out to confirm it seems to have submitted properly.