CSCI399
Autumn Session, 2009
Assignment 4: Java Servlets
You should complete exercise 4 before starting this assignment.
Aim
This assignment aims to give you basic skills in the deployment of a Java "web application" in an application server.
Objectives
The objectives are for you to:
In assignment 4, you are to use the traditional approach of application defined "beans" and use of JDBC. In assignment 5, you will meet the newer "Java Persistence Architecture" model where much of the code for data persistence is generated entirely automatically.
We will be using the combination of Netbeans 6 and Sun's AppServer 9 as installed on the Ubuntu Linux machines in the laboratory.
AppServer 9 ("glassfish v2") is a composite server with a "Web" server and an "EJB" server component. The Web server is a modified version of Tomcat. (The Ubuntu installation also has a copy of the standard Tomcat 6, but in assignments 4 and 5 you should deploy onto the AppServer.)
Netbeans greatly simplifies deployment as compared to older style development environments. You create your "web application" (webapp) with its servlets, beans, static HTML pages, and libraries and simply "build" then "deploy". You can then aim a browser at your webapp on your server. (You can use System.out.println tracer statements in servlet code - such outputs appear in the server log which you can read.)
Netbeans has a "wizard" that helps create the web.xml deployment files needed for your servlets. While you can view (and even edit) the XML yourself, it is much easier to use the dialogs in this wizard.
You will need to define database connections, and also a set of "users" for your applications. The users will be assigned roles that will be mapped to application specific roles that determine access privileges. You will also need to add libraries to the default set supplied by Netbeans. These aspects of the assignment should be covered in the associated preliminary exercise.
Tasks
For reasons best known to themselves, the RentADump property rental agency has decided not to go with domain.com.au but instead create their own web-site that presents the properties that they have listed for lease.
RentADump requires the development of a web-application that:
The following table definitions are suggested for use with Oracle; you may wish to adapt them slightly:
drop table photos;
drop table properties;
drop sequence photoseq;
drop sequence propertyseq;
commit;
create sequence photoseq increment by 1 start with 1;
create sequence propertyseq increment by 1 start with 1;
create table properties (
propertyid number primary key,
streetaddress varchar(48),
suburb varchar(32),
postcode number,
accomtype varchar(16),
beds number,
baths number,
cars number,
maxres number,
avail date,
weeklyrent number,
furnish varchar(16),
description clob,
constraint prop_accomtype
check (accomtype in ('House', 'Townhouse', 'Apartment')),
constraint prop_furnish
check (furnish in ('Furnished', 'Part furnished', 'Unfurnished'))
);
create table photos (
photoid number primary key,
propid number,
phototype varchar(4),
photocode varchar(4),
photodata blob,
constraint photo_type
check (phototype in ('Int', 'Ext')),
constraint photocode_type
check (photocode in ('GIF', 'JPG', 'PNG')),
constraint photo_prop
foreign key(propid)
references properties(propertyid)
);
DBInfo
helper class to establish a database connection. Submission
The due date for submission will be announced in lectures; provisionally set for May 22nd.
As with previous assignments, you will submit a report on your work for assessment. This should be a word processed document converted to PDF format; it will need to include some screenshots of your work.
Each servlet should be presented in a separate section. You should provide a listing of the servlet code and of any supporting classes that you defined. A source listing of the wizard generated web.xml file should be included.
There should be screen shots illustrating your forms and responses and evidence to prove that access controls are applied. Selective listings of database tables might also be used as evidence for a working application.
You should use stylesheets to set an overall style for your site, and should aim to create something more attractive than my demonstration pages illustrated above.
For this assignment you submit your work using the command:
turnin -c csci399 -a 4 A4.pdf
As always, late submissions are possible for a few extra days; in this case they will take the form:
turnin -c csci399 -a 4late A4.pdf
Marking