CISC370, Homework H05, Summer 2007:
Tomcat, Servlets, and JSPs

Due: Thursday, 08/09, 11:55pm

Introduction

There is not enough time left in the semester to do a major homework or project, but there is too much time left just to declare victory and "cancel the remaining three classes"—especially in a comprssed 10 week semester.

So, we will do a minor homework—one that is fairly "cookbook", but that will introduce you to an important Java-related technology: Servlets. Servlets are the building blocks of Java-based server-side web applications. They are used to drive many commerical web applications including RateMyProfessors.com, and Delta.com.

It is a pretty sure bet that you are using a Servlet/JSP-based application when you see .jsp or servlet in the URL.

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

Required Reading

  1. topics/java/basics/compilingOnStrauss/compilingOnStrauss.txt
  2. topics/tomcat/generalInstallAdvice/sharedInstall.txt

Overview

This assignment assumes your strauss account is configured for Java 5.0, which it should already be.

In this assignment, you will:

  1. Setup a Tomcat server on strauss under your home directory.
  2. Deploy the web app from Chapter 1, pages 30, 31 in HFSJ (this is an example of a Servlet).
  3. Demonstrate that your web apps works to your instructor or TA.

Step 1: Setup a Tomcat server on strauss

The steps to set up a Tomcat server on strauss are provided in the file:

topics/tomcat/generalInstallAdvice/sharedInstall.txt

Step 2: Deploy the web app from HFSJ pp 30-31

You'll need p. 30-31 of your textbook. You should also look at the reading notes for p.30 and p.31 which offer some advice on how to tailor the instructions p. 30-31 to the environment on strauss.

To show that this is your web app, modify the app just slightly: change the lines that says:

   out.println("<html>" +
  

to say:

   out.println("<html><head><title>Fred's Ch1 Servlet</title></head>" + 

except, put your name, not Fred. Unless your name is Fred. You may also modify the part that says HF\'s Chapter 1 Servlet inside the <h1> element to be Fred\'s Chapter 1 Servlet if you like.

Step 3: Demo your p30-31 servlet to your instructor/TA

We'll give you some time in class during the next few class periods in which you can do this.

Or, you can just send us an email with subject line "CISC370 H05 Step 4 " and the URL of your app in the body.; we'll know it's yours because of the name in the Title bar. Once we've noted that it is working, we'll send a return email inviting you to shutdown your server (to conserve CPU cycles on strauss—that "funny money" that shows up when you log in.)

 

Step 4: Familiarize yourself with MVC

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

MVC is an example of a design pattern. According to Wikipedia, a design pattern is a "general repeatable solution to a commonly occurring problem in software design. " You will hear a lot about design patterns if you pursue a career in professional software development, so it is good to familiarize yourself with the concept.

For this part, look through p. 70-91 from the HFSJ handout

These pages from Chapter 3 of HFSJ walk 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.

Be sure to check the errata for typo corrections

Step 5: 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 Tomcat server. (This version contains only the "C" in "MVC").

Step 6: 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 7: 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 the wiki page 07J_H04

When you are finished with the final Beer-v1 servlet, make a link to it the page 07J_H04 on the course wiki.

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

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 H03 assignment instead of Beer.

Keep development and deployment directories separate!

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

Test and deploy your servlet on your Tomcat server

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 the 07J_H05 wiki page also

When it is finished, make a link to it from the 07J_H05 wiki page.

Create a tarball or zip file of your development directory and submit it on WebCT.

Grading Rubric (100 pts total)

Choice points opportunities:

You can find some advice on how to do this by consulting the following assignment from CISC474:

http://www.udel.edu/CIS/474/pconrad/07S/hwk/H07.html

To get the choice points, you should do this work by the regular deadline, and include it in your submission.


Valid XHTML 1.0 Valid CSS!