CSE 135: Server-Side Web Languages

Summer 2016 | University of California, San Diego CSE Department

Homework #2 - Language and Architecture Basics

This homework presents an opportunity to prove to ourselves that the languages and architectures used in Web programming are quite related to each other. Their are trade-offs with the different approaches, but our small test programs we write in this homework might sway us not to get caught up in the syntax of the moment battle and focus on the parts of Web development that are more similar than different.

Our aim for this homework is to write the following small programs as tests of core server-side Web basics:

  1. "Hello World" – A server-side program that print “Hello Web World from Language X on date time stamp” where X is the language being used. The page also should randomly use a background color of either red, white or blue just to show you besides the date that it is a generated page.
  2. "Environment Variable Echo" - If you load this page in the browser the program will print out all the environment variables from the request and related values.
  3. "Form Collection" - Write a valid HTML5 form that collects a user’s first and last name with text boxes and their favorite color with a pull down, and a pull down to send the data with a method (get or post) that sends data to a program called "echo" and have it spit out “Hello <username> from a Web app written in X on data time” set to some specified background color. You will need a small bit of JavaScript to change the "method" attribute of the form so it sends differently
  4. "Session Test" - Write two pages (sessionpage1 and sessionpage2). On sessionpage1 collect the users name. Save this value to a session. Click a link and load sessionpage2 view a message on page2 that says "Hi <username> nice to meet you!" if the value is set. If the value is not set in session write out "Howdy stranger...tell me your name on page1!" Add a button on sessionpage2 labeled "Clear Session" if you hit that button it will kill the session data. All sessionization should be performed using standard cookie approach.
  5. You will write all these programs in 3 different ways

    1. CGI with Perl (you may use a CGI helper library if you like - quite important for the sessioning!)
    2. PHP
    3. NodeJS (with or without Express)

    Your current server should handle the CGI and PHP content already. If not fix this first before starting. You likely will not have NodeJS running yet so once you are at that step add it to your hosted environment before coding. You should approach the programs in order first with CGI, then PHP, then Node. The order may reveal something itself. Advanced students may write the same 4 examples as Apache Modules if they desire for a bonus, but should speak to the Prof. before undertaking that effort for advising.

    Back to CSE135


  • 3pts for hello world (1 pt per approach)
  • 3pts for environment echo (1 pt per approach)
  • 6pts for form collection (2pts per approach - 1 for form and 1 for code)
  • 10pts for session demo (3pts each for PHP and Node, 4pts for CGI)
  • 3pts for Readme and quality

Total: 25pts

Please indicate that you are done to the TA via e-mail by 11:59 PM 8/16. Your code should be in your repo at that time.