This project must be done individually. No copying is permitted. The goal of this project is to learn server-side web programming using NetBeans (Java servlets). More specifically, you will develop the same bookstore web application from Project 2 using NetBeans.
You will do this project on your own PC/laptop. It will require to install both JDK Java and NetBeans. You don't need to have a full web server. You will need about 300MB of disk space. Please let me know if you don't have access to a PC or don't have enough disk space.
To practice, implement the MyProject application described in the class slides.
You can get help by pushing the F1 key in NetBeans. Also Javadocs are very important. If you find a class or method that you don't know you right-click and select Show Javadoc.
The following web pages provide more help. Use them as a reference only.
Call your project: Project3. You must create your book database using the Apache Derby database system: You select Tools/Java DB Database/Create Database to create a new database. In NetBeans, you can recreate your bookstore database by opening the .sql file you created in Project 2, by selecting your database in the Connection: entry, and by highlighting and executing the SQL commands.
Hints: The selected books must be displayed in a Checkbox Group. See multi-select listboxes, which are similar to checkboxes. After you drag and drop a Checkbox Group in a page, you right-click on it and select Bind to Data/Bind to Object. You can then see that it is bound in the page bean to the parameter options of type Option and to the parameter selectedValue of type Object. Look at the Javadoc of the com.sun.webui.jsf.model.Option class to see how to handle an Option. Basically an Option has the properties Label and Value. The Label of a checkbox is the text displayed next to the checkbox while the Value is an Object associated with it. For a book, the Label is a string that contains the book title, price, etc, and the Value is the book id. When the user selects one or more checkboxes, the component's selectedValue property contains an array of the selected values. You need to store Option in the SessionBean instead of the page bean so that the selected books are kept throughout the session.
For example, to create a small checkbox group that contains user-defined checkboxes, add the attributes:
Option options; String selected;in the SessionBean of your page, then insert the code:
options = new Option; options = new Option("1","AAA"); options = new Option("2","BBB"); selected = new String; selected = "2";in the _init() method of the SessionBean, then bind the CheckBox Group to the options session attribute. Then right-click on the CheckBox Group and select Property Bindings, and bind selected to the selected attribute in your SessionBean. When you run it you will see two checkboxes AAA and BBB where the second is checked. If you don't get what you have expected one reason may be that you haven't cleaned before you run.
Go to the subdirectory NetBeansProjects in your home directory and then go inside Project3/src/java. You will see a subdirectory project3. You need to zip this directory into project3.zip. In Unix this is done using:
zip -r project3 project3(or you can use tar cf project3.tar project3 to create a tar archive). DO NOT zip the entire Project3 directory as it will be more than 10MB. Zip only Project3/src/java/project3. Use the form below to submit your project3.zip or project3.tar file.
Last modified: 02/18/09 by Leonidas Fegaras