POPL Assignment 5 - Web Programming in Scheme
In this assignment you will use the PLT Scheme Webserver, which 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.
You will again write the authoring half of a simple blogging tool. Requirements for this application are equivalent to the requirements found in assignment 3
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/add.ss contains the code for the servlet at the URL http://localhost:8080/servlets/examples/add.ss
. There are many examples in this directory; we suggest reading and tweaking with a few of them to get started.
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 "servlet.ss" "web-server")
(lib "plt-pretty-big-text.ss" "lang")
(lib "datatype.ss" "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.
To hand in this assignment, email a zip file of all the sources for your web application to S.D.Vermolen at tudelft.nl. Because of the end-of-the-year holidays, you have more time to complete your application than usual. The deadline is 12 January. As before, this is not an individual assignment, hand in your solution in pairs.
- 09 Dec 2008