CS2a/Spr09: Introduction to Computers
HW3 - Servlets

HW3: Servlets
due Thursday 3/5/2009, 11:59pm
100 points

You may work on this homework in groups of 2 or 3. If you do so, then you should put all of your names in the template so that your names all appear on each page of your hw3 assignment.

You are to create a folder called hw3 in side your class server space (on the popper.cs-i.brandeis.edu:8088 server) by visiting the URL

http://popper.cs-i.brandeis.edu:8088/tim/cs2aspr09/home/YOURUNETID/hw3/hw3a-init.servlet.
except that you use your unetid instead of YOURUNETID. You will need to create the following files in this folder:
hw3a-init.servlet 
hw3a_init.css     

hw3b.servlet      

hw3c.html         
hw3c.servlet      


hw3d.css
The requirements for this files will all be described in detail below.

hw3a - a template

You should write two files
hw3a-init.servlet 
hw3a_init.css     
The first should define a template of the form
(define (YourUNETID-hw3page Title Body)
   ...
)
as we have done in class, but your template should generate an HTML page that has the correct DOCSTYLE tag and it should also contain four divs with ids top,sidebar,content, and footer. The Body parameter should go in the div with id body, but the other three divs should contain info about hw3. For example, You should use this template for each html and servlet file you write in hw3. Also, all CSS should be in the hw3a_init.css file and you should use absolute positioning to place the four (or more) divs in your template.

hw3b.servlet

This should be a servlet that generates a webpage which can only be seen from an IP address that begins with 129.64. The servlet should use the template you created in part a. If the IP address is correct it should also report on the users browser type, using
[(.getHeader request "User-Agent")]
and the page from which the user came to this page, using
[(.getHeader request "Referer")]
For example, your browser is
CCBot/1.0 (+http://www.commoncrawl.org/bot.html)
and you got to this page from the page
#null

hw3c - an html form and a servlet that does calculations with input from the user

You should write two files for this problem:

hw3c.html
hw3c.servlet
Both the HTML and servlet files should use the template you created in part a above. The hw3c.html file should contain a form that ask the user form information including some numeric information (e.g. age). It should contain at least the following tags:
form
input (with types text, password, radio, checkbox, submit, and reset)
select
The form should ask the user for a unetid and also a password.

The hw3c.servlet file should accept all input collected by the hw3c.html form. If the user does not supply the right password (hw3yeah!) it should generate a "bad password" page. Otherwise, it should send an email to the user from you and to you from the user, repeating the information sent from the html form (i.e. the servlet parameters). Then it should do some calcuations with the numeric data and generate a webpage contain all of the original data (the servlet parameters) in addtion to the computed values.

Finally your hw3 should have a purpose. For example, pre-registration for some event. Or conducting a survey (where the results get sent to you), or performing some useful or interesting calculations...

hw3d.css - a CSS page for a particular class of webpages

Finally, I want you to try writing some CSS for a page that already exists. Visit the following page:
http://dennett.cs-i.brandeis.edu:8080/fm/loginreg/viewmajor.servlet?majorid=Communication+and+Media+Studies
At the bottom is a page that allows you to select a custom CSS page. Click on that link and then enter the URL fo your hw3d.css page, which should be something like:
http://popper.cs-i.brandeis.edu:8088/tim/cs2aspr09/home/YOURUNETID/hw3/hw3d.css
Here is a list of the relevant CSS selectors for this page, where indentation indicates that the indented tags are contained in the tag above...
div#headline             top of the page
  span.pagetitle         title of the page

div#body                 main contents of the page
  div#addcourse          form to edit the "theme"
  div#progname           name of the theme
  div#progdesc           brief description of the theme
  div#contributors       box containing a list of the people who contributed to this theme
    div#contributorlist  the list of contributors themselves

  div#courses            box containing the courses in the theme
    div#courselist       div containing the courses
     span.count          number of people choosing this course
     span.coursenum      course number (e.g. SOC 146A)
     span.title          title of the course (e.g. Mass Communication Theory)

div#footer               footer containing a menu of links to servlets on the site (e.g. login/logout, ...)

Sample Code

You can look at sample code for these problems at http://popper.cs-i.brandeis.edu:8088/tim/cs2aspr09/home/tjhickey/hw3/ Feel free to study these examples, but your work should be substantially different from these examples.

Extracurricular Opportunity!

If you get ambitious and create a really interesting servlet for hw3c, you can register to submit a poster at the New England Undergraduate Computing Symposium (http://www.neucs.org ) which has a category for students in first year computer classes (and that would be you!) The symposium will be at Wellesley on Saturday 4/18/09 and will consist of two poster sessions, a keynote, a lunch, and an hour of selected student presentations. The deadline for submission to the symposium is March 6th. Let me know if you are interested and have some ideas. This will look good on your resume. See if you can think of some applications in the "social justice and IT" category as well!
Creative Commons License
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 2.0 Generic License