Department of Computing Science Umeå University

Assignment 4 - File Uploads

Due: 2007-08-28, 10:00

The assignment shall be solved individually.

The purpose of this assignment is to further demonstrate the use of Servlet libraries and databases in Java, and show how they tie into web architectures based on JSP.

In this assignment, you will create a web application which handles images in a gallery. The data in the gallery (i.e., images and comments) will be stored in a database and accessed via JDBC. The database schema and all SQL for the assignment will be provided, including a fully functional JDBC accessor class. You are free to choose the appearance and theme (how images are presented and handled) of your application, but a minimal functionality set required includes

  • An administration interface where users can upload images into galleries (up to 5 images at a time). User should be able to both create new galleries and add images to current galleries.
  • Some kind of page where visitors to the site can comment on images and galleries
  • A presentation which presents the galleries in the database
  • A presentation which presents the images in a gallery
  • A presentation which presents comments about images
The three presentation pages mentioned above may or may not be separate JSP pages, the design of your solution is up to you! Note that in order to receive a passing grade on this assignment you will need to create a functional web application - not just a set of web pages which implement the absolute minimal feature list above. Add your own personal touch and create something you would like to use yourself!

For inspiration on how to structure your gallery application, have a look at Flickr

Laboration environment

For this assignment, you will need to complete your laboration environment with two additional libraries handling file uploads.
These are

and are more commonly known as Apache Jakartas commons file upload and I/O servlets libraries.
Download these files and place them in 5dv076/apache-tomcat-6.0.13/lib/

These libraries are used to handle file uploads, where file data is encoded in the body of HTTP requests. An example of how to use the database accessor in conjuction with these classes can be found in fileuploads.jsp.
Further information on these libraries can be found on their respective Apache commons webpage:

Download assignment4.jar and place it in your web applications library directory (5dv076/username/web/WEB-INF/lib). This JAR-file contains a data access layer for a two-layer web application architecture. The system is provided in a Java package called assignment4 which contains the following classes:

assignment4.Comment                        <- a gallery comment representation
assignment4.DerbyGalleryAccessor           <- a Derby implementation of the gallery accessor
assignment4.DerbyGalleryAccessor.Factory   <- a factory class for the Derby gallery accessor
assignment4.GalleryAccessor                <- an accessor interface for the gallery database
assignment4.Id                             <- a UUID wrapper class
assignment4.Image                          <- a gallery image representation
Further documentation of these classes is available in a Java-doc package.

The image in this system contains three data fields: id, galleryId and data. The Image class contains get methods for each of them.
The comments in this system contains five data fields: id, subjectId, timestamp, author and text. The Comment class contains get methods for each of them.
The accessor interface contains methods for storing, retrieving, removing and listing images and comments. The database also implicitly contains galleries - a gallery is created by someone storing an image with a new gallery id. A gallery is updated, or commented, by storing an image of a comment referencing the gallery in the galleryId / subjectId field.

Using the system: To use the system you simply instantiate an accessor: GalleryAccessor accessor = DerbyGalleryAccessor.Factory.getInstance(); and retrieve, store or search for the data you are interested in:

  Id[] galleries = accessor.listGalleries();
  for (Id galleryId : galleries)
  {
    Id[] images = accessor.listImages(galleryId);
    Id[] galleryComments = accessor.listComments(galleryId);
    out.println("gallery: " + galleryId +
                " (" + images.length + " images, " +
                galleryComments.length + " comments)");
    for (Id galleryCommentId : galleryComments)
      out.println("comment: " + galleryCommentId + "<br>");
    for (Id imageId : images)
    {
      Id[] imageComments = accessor.listComments(imageId);
      out.println("  image: " + imageId +
                  " (" + imageComments.length + " comments)<br>");
      for (Id imageCommentId : imageComments)
        out.println("    comment: " + imageCommentId + "<br>");
    }
  }
See the environment page for details on the laboration environment.

Examination

Place a WAR-file containing your solution in

~/edu/5dv076/assignment4/

and email the teachers when you have completed the assignment. Also place any Java source-code you may have written in the same library and document its use in a brief report.

Due date

2007-08-28, 10:00

http://www.cs.umu.se/kurser/5DV076/SOM-07/assignments/4/index.html
Ansvarig för sidan: P-O Östberg
Senast ändrad 2007-08-23