Assignment 7, CSC430, Spring 2008
1 Assignment Task
This is a pair programming assignment. You may work with the same partner you worked with last time, or a different one. It’s up to you. As always, you need to make sure that you understand all the text and code in the project.
Repeat the Raw Web Programming assignment using the PLT Scheme Web Server. Instructions for installing and using the PLT Web Server follow.
Include a readme block (commented out, of course) in your submission. In it, you must contrast 3-5 language features that you used in this assignment to the language features encountered in the Raw Web assignments. Even if the members of your team used different languages in the Raw Web assignment, all of you are still responsible for understanding the presented response. The analysis should be 2 paragraphs or fewer. Grammar and word choice matter.
2 Installing the Web Server
The PLT Web Server is included with DrScheme. However, you do need to configure the environment. Download and extract a default environment here.
From the command line, navigate to the root directory of the extracted files, and execute
plt-web-server-text -f configuration-table.ss
Check that the server is running by visiting "http://localhost:8080/" with a web browser. You should see a web page entitled "Welcome to the PLT Web server"
To quit the server, return to the command line and press Ctrl-C.
3 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.
4 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 "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) |
|
...)) |
Note that these programs are written to explicitly require the useful pieces of the PLAI language (e.g., the define-type and type-case forms). However, these imports are declared explicitly in the template above, so that you should use the "module" language when evaluating this in DrScheme.
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.
5 Quasi-Quoting
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 ,(+ 0 3) 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.
6 Handin
Hand in this program as program 7, using the standard handin mechanism.
7 Acknowledgments
Many thanks to Shriram Krishnamurthi for this assignment.