Skip to topic | Skip to bottom


POPL.Assignment5r1.1 - 10 Nov 2009 - 09:17 - SanderVermolen

Start of topic | Skip to actions

POPL Assignment 5 - Web Programming in Scheme

In this assignment you will use the PLT Scheme Webserver, to write a simple blogging tool. The PLT Scheme Webserver is based on the concept of continuations that we studied in class. You may work on this assignment in groups of two. In your handin include a comparison of features of web programming in Scheme with web programming in another environment that you are familiar with such as Java servlets or PHP.

The Application

You will write the authoring half of a simple blogging tool. (The publishing half that would complete the tool is outside the scope of this assignment.) Although this program is quite simple, it is representative of the core of much larger web software (just as the interpreters we write in this course are themselves quite lean, but represent the core of large programming languages).

Weblogs (“blogs”) are web pages that consist of a list of posts ordered so that newer content is at the top. For our purposes, a post is a title, some text, and a post date. You must assume that the title and body are plain, ASCII-encoded text. In particular, this means that your software will need to escape HTML entities. For example, typing <b> into a text field should not make any part of the post bold.

The main page of your web application should have:

  • A list of posts, sorted correctly by date and spread across multiple pages, such that each page shows at most 10 posts (like the Google search results)
  • A form for creating new posts, with a field for the title and a text area for the body

Upon submitting the form, the user should see a preview page that shows the post along with its date. The post is not shown on the main page until the user confirms it from the preview page, either through a link or a form button.

Entered posts need to be persisted to disk and visible from any computer accessing the web application. You may use a database for this purpose, but are also allowed to simply store the posts in files on disk manually. Yet, keep in mind that using a database is probably easier.

Installing the Web Server

  • Please take a look at the attached installation tutorial
  • More documentation about the web-server can be found in
    • the manual, available from the PLT Scheme documentation
    • the paper Implementation and Use of the PLT Scheme Web Server by Shriram Krishnamurthi, Peter Walton Hopkins, Jay McCarthy, Paul T. Graunke, Greg Pettyjohn, Matthias Felleisen Higher-Order and Symbolic Computation

Finding Servlets and Pages

Static content (web pages, images, etc) are found in htdocs/. For example, htdocs/index.html is the page you see when you visit http://localhost:8080/.

Servlets are found in servlets/. For example, the file servlets/examples/ contains the code for the servlet at the URL http://localhost:8080/servlets/examples/ There are many examples in this directory; we suggest reading and tweaking with a few of them to get started.

Writing Servlets

You may write your servlets in DrScheme and save them in the servlets/ directory. Use this template for your servlets:

(module servlet mzscheme
  (require (lib "" "web-server")
           (lib "" "lang")
           (lib "" "plai"))
  (provide interface-version timeout start)

  (define interface-version 'v1)
  (define timeout +inf.0)
  (define (start initial-request)
    ; initial page goes here

If you change a servlet while the server is running, the web server will not reload it unless you explicitly instruct it to do so by visiting http://localhost:8080/conf/refresh-servlets. Note that when you do so, all suspended servlets are terminated.


You may notice sample servlets quoting lists with ` instead of '. This is called quasiquoting, as opposed to quoting. Quasiquoting lets you evaluate specific elements of a quasiquoted expression instead of directly returning the expression. To force evaluation of an element in a quasiquoted expression, prefix the element with a comma. For example, to generate the list '(1 2 3 4) you may write `(1 2 ,(+ 1 2) 4). Quasiquoting is a convenient way to insert dynamic elements into HTML templates. If you want more information or examples, the Scheme standard is a good place to look.


Your handin should consist of a zipped file containing all sources required to run your application. Follow the Handin Guidelines. This is not an individual assignment, hand in your solution in pairs.

-- SanderVermolen - 10 Nov 2009

You are here: POPL > Schedule > Assignments > Assignment5

to top

Copyright © 2003-2018, Software Engineering Research Group, Delft University of Technology, The Netherlands