Project 3
Web Application Development using NetBeans

Due on Friday February 22 before midnight


Description

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.

Platform

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.

After you execute Netbeans for the first time, you need to add Tomcat as a web container (if it's not already set up): Select Tools/Servers from the menu and push Add Server. Select Tomcat 6.0. You also need to specify the Catalina Home directory which can be found by searching for the directory apache-tomcat-6.0.14 or something like that (eg, on Windows the default is C:\Program Files\Apache Software Foundation\Apache Tomcat 6.0.14) and give a username (say tomcat) and a new password.

To practice, implement the MyProject application described in the class slides.

Documentation

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.

Project Requirements

You need to implement the bookstore web site described in Project 2 using NetBeans, instead of PHP. You should not use any PHP or JavaScript code.

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. 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[2];
options[0] = new Option("1","AAA");
options[1] = new Option("2","BBB");
selected = new String[1];
selected[0] = "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.

What to Submit

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.


Submit this file:


Last modified: 02/18/08 by Leonidas Fegaras