| Sun Java System Application Server |
The Duke's Bookstore sample application illustrates the tasks involved in programming using Java Server Pages (JSP). This application allows users to retrieve available books from a database table, displays details of the book, add and remove books to a shopping cart and check out the books. The Duke's Bookstore implements the Model-View-Controller design pattern and database helper object for accessing database.
The Bookstore sample and its associated files are in the
install_dir/samples/webapps/apps/bookstore directory:
docs - Contains docs for the Bookstorecommon - Contains common files, such as sqlsrc - Contains build.xml and deployment descriptorsThe general instructions for building, deploying, and running sample applications are provided in Building, Deploying, and Running Sample Applications. In reading this document, use the following application-specific variables for this application:
install_dir is the directory where Application Server is installed.
app_dir is the application base directory:
install_dir/samples/webapps/apps/bookstore.
bookstore.war .
Follow this general procedure:
build.xml, is in the app_dir directory.
asant deploy, it will prompt you for
your Application Server host name, administration port, administration user and password
and cluster name. The script will save these values in a properties file, and running it
subsequently will get this information from the file.
When you deploy the application using asant, it will automatically configure the required
JDBC resources. If however, you use Admin Console, you must create the JDBC resources manually.
Follow these steps:
asadmin create-jdbc-connection-pool --host adminhost --port adminport --user adminuser --password adminpassword --datasourceclassname datasource-classname --property User=dbusername:Password=dbpassword:url-property="jdbc-url" --target cluster-name bookstorePool
You must escape ":" and "/" characters.
If using Derby, the url-property would look something like this:
jdbc\:derby\:\/\/localhost\:1527\/DerbyDB;create=true.
asadmin create-jdbc-resource --host adminhost --port adminport --user adminuser --password adminpassword --connectionpoolid bookstorePool jdbc/BooksDB
For more information on using Derby, see Using the Derby Database with Sample Applications.
After you have built and deployed the application, started the database server, and configured resrouces, you can run the sample application by entering the following URL in your web browser:
http://ws-host:ws-port/dukesbookstore/enter
Where ws-host is the hostname of web server with the load balancer plugin and ws-port is the port one which the web server is running.
The following images illustrate running the application.
Duke's Bookstore context root (home) page
Click on the "Start Shopping" link to continue.
Book Catalog Page
Click on book titles to add them to your shopping cart.
Shopping Cart Page
Now, stop the instance that served the request. For information on how to do this, see Running the sample Applications. After the instance is shut down completely, click on the "Check Out" link. The second instance will retreive your shopping cart contents and then the application will display the correct purchase amount.
On the cashier page, click on the submit button to check out.
If you have problems when running the application, try the following:
asant sql if using Derbyasant undeploy, asant clean and then asant all.
Copyright © 2006 Sun Microsystems, Inc. All rights reserved.