Lab3: HTTP; CGI

Last modified by Anca Luca on 2010/03/08 00:14

Reference

Standards

Tools

  • Firebug (the "Net" tab), Live HTTP Headers (Firefox add-ons),  Chrome developer tools (the Resources Tab) (bundled with Chrome by default), Opera dragonfly (the "Network" tab) (bundled with Opera by default) or any other browser extension that allows to see http requests & responses.

Practice

The exercises marked with a star (*) are a bit more difficult than the others, if you don't have experience in the field, you should start with the non-starred ones.

Before diving into these exercises, make sure you have managed to run at least one of the examples presented during the web course. They should all work on the students.info.uaic.ro apache server, from your student accounts.

HTTP Requests

Extending the existing scripts examples (the one in the course or the one here), write a cgi script that displays all the HTTP headers received on the request, along with the content of the request. Call this script from a browser (entering the address in the browser bar). Experiment the same for a script called on submitting a form, both with GET and POST methods. How is the script called? Why? What are the differences between the 3 sets of headers & content? What do these differences mean?

Greeter (C)

The attached archive hello.zip contains a small application with a script that returns a greeting to every user that inserts their first and last name. Write the POST version of this application (that uses a POST request to get the page with the greeting).

Guestbook

Create a minimal guest book application (using cgi scripts), that would present the user with a form allowing to insert his name and a comment. On submitting this form, the user will get an illustration of his comment (as described by the comments requirement from the previous lab) along with a small thank you note for his comment.

Stored guestbook

Extend the guestbook application above to store the comment inserted by users in a file, and allow to view all the comments inserted.

Action guestbook *

For the small application above, also allow one to delete a comment by pushing a button or clicking a link. In addition, allow to display just one comment, by clicking the comment header (commenter name). Take special care of the pages displayed after the comment has been added or deleted, of how these actions are performed, and make sure one can store a bookmark to a single comment if they want.

Fibonacci

Write a cgi script which computes and displays the n-th Fibonacci number, where n is  a number introduced by the user in a form.

Fibonacci Redirects *

Just for fun, write a cgi script that displays the n-th Fibonacci number, where n is a number introduced by the user in a form, that uses http redirects to implement recursion.

Tags: cgi http
Created by Anca Luca on 2010/03/07 17:37

This wiki is licensed under a Creative Commons 2.0 license
XWiki Enterprise 2.2.1.27354 - Documentation