Homework Assignments

Homework 4

In this assignment you are to create the student interface for requesting add permits (RequestPermit.jsp). Before a student can request a permit, they must first login to the Website. To do this, you must prompt the student for their e-mail address and password. To validate, the submitted e-mail address and password must match a record in the "Students" table of your MySQL database. Once authenticated, the student's account information should be stored in a session for the duration of their visit. Upon logging in the student should be presented with an interface that contains checkboxes with labels representing all courses that are offered. Below is an example of this list:

CS 120 - Introduction to Website Design
CS 122 - Database Programming
CS 201 - Introduction to Programming
CS 202 - Object Oriented Programming
CS 203 - Data Structures
CS 320 - Web & Internet Programming
CS 345 - Linux & Shell Scripting

The courses that are displayed on the page should be read from a table named "Courses" in a MySQL database. The "Courses" table should consist of the following fields:

id - Unique numeric identifier. The database should automatically set this value upon record insertion.
department - The department that the course belongs to (i.e. 'CS', 'ART', etc...).
number - The course number (i.e. '201', '320', etc...).\
title - The title of the course (i.e. 'Introduction to Programming', 'Underwater Basket Weaving', etc...)
catalogNumber - The catalog/section number (i.e. 15002, 15283, etc...)

You should pre-populate this table with course information from a minimum of five (5) computer science courses offered this quarter (Spring 2010).

A student will check a box for each course that requires an add permit. Upon submitting the form, the student should be re-directed to a confirmation page displaying all permits/courses requested. This page should allow the user to cancel the request, or submit the request. Upon cancelling, the user should be re-directed to the Permit Request Page, but you do not have to remember their selections. That is to say, you are not required to use "sticky forms" if the user clicks cancel. (Note: The redirection that occurs when "cancelling" the request SHOULD NOT be handled using JavaScript. Instead, it should be handled on the Server.) If the user clicks submit, you are to record their request(s) in a table named "PermitRequests" in a MySQL database. The structure of the "PermitRequest" should follow the schema below:

id - Unique numeric identifier used to identify individual permit requests. This value should be determined by the database upon record insertion.
courseId - A unique ID that refers to the 'id' field of a unique record in the 'Courses' table.
studentId - A unique ID that refers to the 'id' field of a single record in the "Students" table. This is the student that has made the request.
dateTime - A date/time stamp of when the request was made (the record was inserted into the database).

You should also create a "Students" table with the following structure:

id - Unique numeric identifier that is used to uniquely identify students.
firstName - Student's First Name
lastName - Student's Last Name
phone - Student's phone number
email - Student's e-mail address
status - Student's Status (i.e. 'UNDERGRAD', 'GRAD', 'OPENUNIVERSITY', etc...)
cin - Student's CIN
password - Student's Password

To avoid re-writing your registration page to commit new student records to a database (instead of storing data in the Servlet Context), you should pre-populate the "Students" table with the following students:

Last Name, First Name - CIN - Phone - Status - Email - Password
Doe, John - 123456789 - (323)343-1000 - UNDERGRAD - john@doe.com - abcd1234
Jane, Mary - 987654321 - (323)343-1234 - UNDERGRAD - mary@jane.com - abcd1234
Boxer, Joe - 456789123 - (323)343-6547 - GRADUATE - joe@boxer.com - abcd1234
Doe, Jane - 987132456 - (323)343-7478 - UNDERGRAD - jane@doe.com - abcd1234

Finally, update your administration page (Admin.jsp) from Homework 3 to display from your MySQL database, and not the Servlet Context.


As usual, submit any and all source code, images, etc... to CSNS along with your Assignments.html file. In addition to the usual collection of files, you are required to submit a single SQL script that creates the tables in your project, and populates any and all data that is used. This file should include a variety of CREATE and INSERT statements.

30pts - Login.
20pts - Front-End Design (Display all courses)
30pts - Process Permit Requests
30pts - Database Integration
20pts - Updated Admin.jsp (Read data from database, not Servlet Context)
20pts - SQL Script

Total: 150pts

May 26, 2010 - 11:59pm

Homework 3

In this assignment you are to extend the administrative functionality of you Web application. To do so, you are to create a JSP page named AdminLogin.jsp. This page will prompt the admin for their username and password. If the admin validates (use the credentials from the previous assignment), then they should be re-directed (NOT forwarded) to a Admin.jsp page. If this page is requested without logging in, the user should be automatically re-directed to the AdminLogin.jsp page. If the admin does not validate, your AdminLogin.jsp page should be re-displayed with an error message informing the user that they have entered an incorrect username and/or password.

The Admin.jsp page should display a table of all students who are currently requesting an add permit. This table should contain the name, CIN, year, and course that the student is requesting. If the student is requesting more than one permit for several courses, the student will appear multiple times in this table. The last two columns of the table should read "status" and "action". Status should display current status of the permit. If the admin has not yet granted or denied add permission, then the status should read "Pending". Otherwise, the status should read "Granted" or "Denied" depending on the admin's actions. The last column ("action") should contain two buttons per row. These buttons should read, "Approve" and "Deny". When an admin clicks on "Approve", then the student will be granted an add permit for the course requested. When the admin clicks "Deny", then the student will not be granted add permission. After the admin clicks a button, the JSP page should refresh with the student's add permission updated.

You are allowed to use Scriptlets and Servlets in conjunction with your JSP pages, but you MUST use JSP to display the front-end to the user.

May 7, 2010 - 11:59pm

Homework 2

This assignment will build upon Homework 1. In this assignment you are to instantiate an object of type User for each user that registers on your site. Each new User objects should be stored in an ArrayList. This ArrayList should then be stored in the Servlet Context of your Web Application. The UML for the User class can be found below:

User UML

Next, you are to implement an Administration Page. The Administration Page will be used by a single Administrator once the site is operational. The admin will simply login to your application via the Admin page, to view and approve/deny all students with pending permit requests (future functionality, not part of this assignment). The administration page should maintain the same look and feel as your New User Registration Page. On the Admin page you should only prompt the user for a username and password. No other form fields should be present on the admin page.

Upon submission, if the username does not match "admin", and the password does not match "abcd", then you should redisplay the admin page with a message that reads, "Invalid username and/or Password".

If the Admin's username and password are correct, you should redirect the user to a new Servlet named ViewAllUsers. The ViewAllUsers page should display all users that are currently registered in a tabular form. Include all user fields in your table.


10 pts - User Class
20 pts - All features of Homework 1 are still functional
20 pts - Admin Page
20 pts - Admin Page Validation
30 pts - View All Users Servlet

Total: 100pts

April 14, 2010 - 11:59pm

Homework 1

This quarter we will develop a Web Application to facilitate the Computer Science Department in issuing Add Permits to students. This site will be developed incrementally, with the first installment being a registration page.

A student must have a valid account in order to utilize the site. To create an account, a student must register using the following form:

Registration Form

The registration form should be a servlet named Register with the URL-Mapping: /homework1/Register. The action of the form should also be Register. That is to say, the form will submit all form data to itself. Upon submission, your servlet should verify the following:

  • The first name, last name, phone, e-mail, CIN and password fields are all populated.
  • A status has been selected.
  • The CIN field contains a 9-digit number.
  • The first two phone fields contain exactly 3 numbers, and the last contains 4 numbers.
  • The e-mail field contains a valid e-mail address.
  • Both password fields are equal and contain at least one letter and number, and has a minimum length of 6 characters.

If an error occurs during validation, your servlet should re-display the form with an error message below each field that contains an error. For example, if the user did not submit a first name, the following should be displayed:

Error Message

All fields that contain an error should be redisplayed empty. Fields with valid data should be displayed with the data that was submitted. In other words, a user should not have to re-type already valid data. The practice of automatically filling form data when errors occur is known as sticky forms.

If all fields validate then your servlet should display the following:

Successful Registration

All CSS and image files necessary to complete the assignment, as well as sample HTML files can be found in the zip file below:



20 pts - Validation
20 pts - Presentation
20 pts - Sticky Forms

April 5, 2010 - 6:00pm


CSNS All files must be submitted to CSNS prior to the due date/time.