The projects 2
Project 1: Product Maintenance 3
Project 2: Product Maintenance with custom tag validation 9
Project 3: Product Maintenance with a database using JDBC 10
Project 4: Product Maintenance with a database using JPA 11
Project 5: Product Maintenance with SSL and authentication 12
Project 6: Product Maintenance within the Music Store web site 14
2 Projects for Murachs Java Servlets and JSP (3rd Edition)
The projects
The following pages present the user interface, operation, and specifications for each
project. As you view these pages, remember that each project builds upon the previous
projects.
3 Projects for Murachs Java Servlets and JSP (3rd Edition)
Operation
When the application starts, it displays the Index page. This page contains a link that
leads to the Products page that can be used to add, update, or delete products.
To add a new product, the user selects the Add Product button. This displays the
Product page with all text fields empty. Then, the user can fill in the text fields and
click on the Update Product button to add the product.
To edit an existing product, the user selects the Edit link for the product. This
displays the Product page with all existing data for the product displayed. Then, the
user can edit any entries and click on the Update Product button to update the data for
the existing product.
To delete a product, the user selects the Delete link for the product. This displays the
Confirm Delete page. Then, if the user confirms the deletion by selecting the Yes
button, the product is deleted and the Products page is displayed to reflect the new
data. If the user selects the No button, the Products page is displayed.
Specifications
Use a Product class like the one shown later in this document to store the product data.
Use a ProductIO class like the one shown later in this document to read and write the
product data to a text file named products.txt in the WEB-INF directory.
Use a text file like the products.txt file shown later in this document as a starting point
for the products that are available to the application.
Use server-side validation to validate all user entries. In particular, make sure the user
enters a code, description, and price for each product. In addition, make sure the
products price is a valid double value.
If possible, get the Product.java, ProductIO.java, and product.txt files from your
instructor or trainer. Otherwise, you can create these files yourself.
5 Projects for Murachs Java Servlets and JSP (3rd Edition)
import java.text.NumberFormat;
import java.io.Serializable;
public Product() {}
import java.io.*;
import java.util.*;
import music.business.*;
products.add(p);
}
line = in.readLine();
}
in.close();
return products;
7 Projects for Murachs Java Servlets and JSP (3rd Edition)
} catch (IOException e) {
System.out.println(e);
return null;
}
}
out.close();
} catch (IOException e) {
System.out.println(e);
}
}
Specifications
Use a custom tag to mark empty fields that are required on the Product page with an
asterisk.
10 Projects for Murachs Java Servlets and JSP (3rd Edition)
Specifications
Use a class named ProductDB thats in the music.data package to add, update, and
delete the products in the Product Maintenance application. This class should use
JDBC.
Use a connection pool as described in chapter 12.
Use the music database thats created when you follow the procedures described in
appendix A (PC) or B (Mac).
11 Projects for Murachs Java Servlets and JSP (3rd Edition)
Specifications
Add JPA annotations to the Product class.
Use a class named ProductDB thats in the music.data package to add, update, and
delete the products in the Product Maintenance application. This class should use the
EclipseLink JPA provider.
Since the EclipseLink JPA provider automatically creates a connection pool, please
delete any old code that creates a connection pool for JDBC.
Use the music_jpa database thats created when you follow the procedures described in
appendix A (PC) or B (Mac).
12 Projects for Murachs Java Servlets and JSP (3rd Edition)
Specifications
Restrict access to all pages except the Index page. Only allow users in the programmer
role and customer service role to access the rest of the pages in the Product
Maintenance application. To do that, use the UserPass and UserRole tables in the
murach database to define the usernames and passwords for these roles.
Use a secure connection for all pages except the Index page.
14 Projects for Murachs Java Servlets and JSP (3rd Edition)
Specifications
Add the JSP files for the Product Maintenance application to the admin directory of the
Music Store web site.
Add the controller servlet for the Product Maintenance application to the music.admin
package of the Music Store web site.
Modify the admin/index.jsp file of the Music Store web site so it includes a button that
starts the newly added Product Maintenance application.
Modify all necessary JSP, CSS, Java, and XML files within the Music Store web site
so they work with the newly added Product Maintenance application.
In the controller for the Product Maintenance application, use the getRequestURI
method to determine which action to process as shown in chapter 22. If the URL
doesnt match any actions in your application, use the sendError method of the
response object to send a 404 error to the user to indicate that the page isnt available.
Dont break the other applications in the existing Music Store web site.