To get your participation credit, make sure you
upload your Definitions file to turnin before you leave the lab!
(This work will not be graded---full credit just for submitting.)
This lab looks at the problems with managing state information when programming on the web, specifically at the need for "hidden fields" in forms.
As a motivating example, let's consider the following bad experience reserving a hotel on the web (which can actually happen if you disobey the Don't Press the Back Button! admonition on poorly coded web sites):
You need to use the Pretty Big language level for this lab.See hints for using HTML in Racket.
Put your name in a comment at the top of the Definitions area.
Download the starter file for this lab and the simple http server from class and make sure they are both in the same folder (e.g., both on the desktop). Load and run only the starter file in DrRacket.
In the starter file, you will find data definitions for a trivial hotel database and two versions of an interactive application related to the motivating example above.
Version 1 is a straightforward GUI program, written in the
functional style we have been using in class, which a software
engineer might write as a mockup to explain the desired functionality
to her manager. Run the
several times with various choices to familiarize yourself with the
prompts and behaviors. (Note that this program does not have very
good error checking, because we want to keep it short and it's only a mockup.)
After the mockup is approved by management, our intrepid software engineer writes Version 2, which is the "real" web version that can be run with our simple http server using port 8088.
cs1102-hotel-choicecookie to remember the hotel choice from the search page until it is needed on the confirmation page.
(server 8088)in the Interactions window.
http://localhost:8088/hotel-main-pageinto the url field.
(server 8088)again, however, you must first click on the Run button!
The problem here is that navigating between tabs/windows is a "silent" operation---it happens totally in the browser, so that the server has no way of knowing something has changed. This has exposed a poor design in which information that should be part of the environment of a given page is instead being shared as global state via a cookie.
Hint: Get rid of the cookie and instead add a hidden field (
[type "hidden"]) to the second form to remember the hotel choice. A hidden field holds a value just like any other field, but does not cause a type-in field to be displayed.
Run your revised code with the same sequence of interaction as above and confirm that you have a reservation at the Hilton.
Everybody should be able to finish up to this point.
Warning: Don't put any special characters, such as [ or \, in cookie values, unless you want to look up the special quotation rules, which are not important for this lab.