Complete this assignment with the same team you worked with for Continuations (Written). You and your partner should each understand the entire program but you only need one hand in.
Assignment Task
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 file in your submission. In it, list the names of the people in your group. Additionally, 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 group 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.
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
(If you working on the department's network, you may simply runstart-server.sh
.) - 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
.
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.
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) ; 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.
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.
Handin
Only one member of your group should handin the assignment; we don't want duplicate submissions. From the root directory of your web-server, execute:
/course/cs173/bin/cs173handin pltweb
Ensure that your README file is in root directory.