The Bookstore Application
The Bookstore Application
TABLE 51
Duke's Bookstore Example JSP Pages
Function
JSP Pages
Enter the bookstore.
bookstore.jsp
Create the bookstore banner.
banner.jsp
Browse the books offered for sale.
bookcatalog.jsp
Add a book to the shopping cart.
bookcatalog.jsp
and bookdetails.jsp
Get detailed information on a specific book.
bookdetails.jsp
Display the shopping cart.
bookshowcart.jsp
Remove one or more books from the shopping cart.
bookshowcart.jsp
Buy the books in the shopping cart.
bookcashier.jsp
Receive an acknowledgment for the purchase.
bookreceipt.jsp
The data for the bookstore application is still maintained in a database and is accessed through
tut-install/javaeetutorial5/examples/web/bookstore2/src/java/com/sun/bookstore2/database/BookDBAO.java.
However, the JSP pages access BookDBAO through the JavaBeans component
tut-install/javaeetutorial5/examples/web/bookstore2/src/java/com/sun/bookstore2/database/BookDB.java.
This class allows the JSP pages to use JSP elements designed to work with JavaBeans
components (see
The implementation of the database bean follows. The bean has two instance variables: the
current book and the data access object.
package database;
public class BookDB {
private String bookId =
"0";
private BookDBAO database = null;
public BookDB () throws Exception {
}
public void setBookId(String bookId) {
this.bookId = bookId;
}
public void setDatabase(BookDAO database) {
this.database = database;
}
public Book getBook()
throws Exception {
return (Book)database.getBook(bookId);
}
...
}
The Example JSP Pages
Chapter 5 · JavaServer Pages Technology
137