CISC474, Homework H06, Spring 2007
Model-View-Controller Servlet Tutorial

Introduction

In this assignment, you'll create a Model-View-Controller (MVC) Servlet

This is our introduction what is the central design pattern focus of the course.

You'll need your HFSJ Textbook (Head First Servlets and JSP)

As in H04, you'll read through a chapter in the Head First Servlets and JSP text as you complete this homework assignment—in this case, Chapter 3.

Chapter 3 walks you, step-by-step, through the process of creating a servlet using the MVC design pattern. You'll then repeat that step to solve a "slightly different problem", to convince yourself, your instructor, and your TA, that the knowledge and skills you gained by working through Chapter 3 actually sunk in.

Required Reading

  1. All the required reading from H04
  2. Chapter 2 in HFSJ
  3. Chapter 3 in HFSJ
  4. The Wiki page HowToCompileJavaProgramsOnPorsche to set up your ECL account for compiling with Java version 5.0
  5. The Wiki page TomcatSharedInstallation including the part at the end about setting up a Tomcat server on the clients of porsche.cis.udel.edu.

Assignments that must be completed first

Overview

In this assignment, you will:

Step-by-Step Instructions

Step 1: Reading

Read over all of Chapter 2 in HFSJ, and Chapter 3 up to p. 71.

Be sure to also consult the reading notes for Chapter 2 and the reading notes for chapter 3 so that you know what your instructor considers important from this material.

(Optional: For choice points, post thoughtful reponses to your reading on the discussion boards on WebCT setup for that purpose, with the titles HFSJ Reading Ch1, and HFSJ Reading Ch2. This is also a place where you can report typos or mistakes you find in the reading notes.)

Step 2: Set up Tomcat on your porsche account

Read over the Wiki page HowToCompileJavaProgramsOnPorsche for instructions for setting up your ECL account for compiling with Java version 5.0. Make sure that when you type "java -version" that what comes back looks like the following:

porsche[51] > java -version                                             
java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode)
porsche[52] > 

Read over the material on the Wiki page TomcatSharedInstallation for advice on how to set up your Tomcat server on one of the clients of porsche.

You'll need also to consult the wiki page that lists the machine and port assignments.

You could test your new Tomcat server by either (i) copying the contents of the webapps directly from the $CATALINA_HOME directory, or (ii) by trying to deploy your Chapter 1 servlet, or (iii) do nothing—the next steps in this assignment involve deploying a servlet on this server, and you can wait until that step to see if your Tomcat install is working. I'll leave that choice up to you.

Be sure to set up a cron job to monitor your servlet!

Note that you should also set up a cron job to monitor your Tomcat instance, and restart it anytime it goes down. The instructions on the pages linked to above contain information on how to do this, and why you need to do it.

Step 3: Beer-v1 Controller Servlet (pp. 72-81)

Work through the first verson of the Beer-v1 Controlller Servlet (pp. 72-81) and deploy it on your porsche-based Tomcat server. (This version contains only the "C" in "MVC").

Step 4: Adding the model class (pp. 82-85)

Work through the model class, and the second version of the Beer-v1 Controller Servlet (pp. 82-85), and deploy this on your porsche-based Tomcat server (This version is only the "MC" part of "MVC").

Step 5: Adding the View (pp. 86-90))

Continue with the view part (the JSP), and deploy the third version of the Beer-v1 Servlet (pp. 86-90) on your strauss-based Tomcat server (This is a full MVC version of your Beer-v1 servlet.)

Step 6: Add a link from your CISC474 web page

When you are finished with the final Beer-v1 servlet, make a link to it from your cisc474 web page on strauss (i.e. ~/public_html/cisc474/index.html, the one that is at the URL http://copland.udel.edu/~userid/cisc474). Label the link to this servlet clearly on the web page as "H05 Beer-v1 servlet".

Step 7: Repeat the process for the product you chose in Homework H05

Now repeat this process, creating an MVC servlet that is similar in functionality to the Beer-v1 servlet, but works with your product you chose for your H05 assignment instead of Beer.

Unlike the model class on p. 82, your model class should provide advice for at least four categories. It should return at least two answers for each category, and at least three answer for one of the four categories (these are the same requirements as your table for H05).

Keep development and deployment directories separate!

Note that keeping your development and deployment environments separate is a requirement of the assignment.

(Although you are not turning in code for this assignment, in a future assignment, you will be adding an Ant build file and generating a WAR file—at that point, if you didn't follow the advice to keep development and deployment directories separate, you'll wish you had!)

Test and deploy your servlet on porsche

For the names of the directories in the development and deployment environment, the URL, the class name and "internal secret name" (see p.46 and p.77 in HFSJ) use names modelled after those chosen for the Beer-v1 servlet, but that are appropriate to your servlet (e.g. Skis-v1 or VideoGames-v1 instead of Beer-v1

Link to this servlet from your CISC474 web page also

When it is finished, make a link to it from your cisc474 web page on strauss (i.e. ~/public_html/cisc474/index.html, the one that is at the URL http://copland.udel.edu/~userid/cisc474). Label the link as "H06 product servlet" so that it is easy to find.)

Keep your code, since you'll be using it as the basis of a future assignment. Although you won't be graded on your code in this assignment, in a future assignment you will be submitting it for a grade, so style will count.

Grading Rubric (50 pts total)

Item Description Points
Beer-v1 servlet works The servlet from Chapter 3 of Sebesta works. This is pretty much just "type it in and follow the instructions", so it is only worth 20% of the assignment. 10
Web App Works Student's web app does what it is supposed to do and doesn't crash or return an error 20
Following Directions Student followed directions for assignment (including keeping the development and deployment environments separate, and any other instructions given.) 10
Visual Appearance Produced web page is generally neat (it doesn't have to be a work of art, but it shouldn't be sloppy either) 10

Due Date: Mon 03/12, 11:55PM


Valid XHTML 1.0 Valid CSS!