CS 1102 (A12) Homework 7: Web Forum

Due: October 9 (Tuesday) at 11:59pm via turnin (assignment name hwk7).

Assignment Goals

You need to use Pretty Big language for this assignment!

See hints for using HTML in Racket.

The Assignment

You will write a very simplified web forum site. What I mean by "web forum" is something like our forum on the course site at my.wpi.edu. Your web site will support the following three pages.
  1. The main page, which provides:

    • A chronological list of all the posts so far. Each posting includes:

      • the name of the poster
      • the text of the post (with HTML markup applied---see HTML tip below)

    • A button for adding a new post (which opens an authoring page)

  2. The authoring page, which provides:

    • A field in which to enter your name
    • A field in which to enter the text of the post (which can include regular hmtl markup such as <b> ... </b> for bold face, etc.)
    • A preview button (which opens the preview page in a new window/tab)

  3. The preview page, which provides:

    • A display of how the post will eventually look on the main page (so you can check your markup)
    • An accept button, which submits the post and returns to the main page
    • A cancel button, which returns to the authoring page without submitting the post

Hint: You will need to define four scripts---one each to create the main, authoring and preview pages, and one to handle the accept button. Review the Lab 6 hotel code for examples of how to manipulate HTML, but don't commit the same error of using a cookie in the wrong way (follow your hidden field revision).

Simplifications: Your server does not need to implement persistent storage of the posts (e.g., no files)---just store them in a global variable and use set!. Also, there will be no extra credit for fancy HTML layout. As in the hotel example, we are interested here in the dynamic operation, not the graphical design, of the website.

Test your code with the following interaction sequence to make sure it does not have the same bug as the starter version of Lab 6:

You do not need to provide check-expect's for this homework, as conveniently testing web programs is beyond the scope of this course.


You need to work a little bit to pass the poster's HTML markup through the server so that it is interpreted correctly on the main forum page. For example, if the poster types in
   <b>Warning!</b> This is a bad idea.
you want it to come out on the main page as:
Warning! This is a bad idea.
i.e., in bold, not with the angle brackets. Given the way that x-expressions (xexpr's) are used in the Racket server, the easiest way to do this is to wrap a paragraph element around the string and parse it using string->xexpr. For example,
(string->xexpr (string-append "<p>"
                              "<b>Warning!</b> This is a bad idea."
returns the list (p () (b "Warning!") " This is a bad idea."), which you can then include in your reply page with the correct effect.

What to Turn In

Turn in a single file hwk7.rkt containing your data structures and scripts, which automatically loads the server (like the Lab 6 starter file).

Indicate in a comment at the top what the starting URL should be!

Make sure that all students' names are in a comment at the top of the file.

Back to the Assignments page

This homework is based on an assignment in CS173 by Shriram Krishnamurthi at Brown U.