IT350 - Web and
Last week we have learned about cookies and more about Perl. In this lab you will practice those skills and you will install Perl on your Bancroft computer.
You must create a folder on your Web drive called "Lab09" (without the quotes) and store your work in that directory.
Download cookie_js.html from here (right-click and "Save link as...") and store it in your Lab09 directory.
1. Java Script - Add cookies: Modify the cookie_js.html such that:
a. Your page stores two distinct pieces of information using two cookies (e.g., user’s name and favorite color)
b. Your page uses the two pieces of information stored in cookies to display some personalized (style and/or content) text. The user should not be required to enter any information, if cookies are present.
c. The page does something reasonable when no cookie is stored (the first time the page loads) – be sure to check this at the end!
d. Both pieces of information can be changed by the user, and the new information is stored in cookies
e. All of the functionality described above should be obvious to the user: what cookies are stored, how the information stored changes the page, how can the user change what is stored.
Example: you store the user’s name and favorite color. When the page loads, the page displays their name and changes the background to their favorite color. The users can change the values stored in the cookie by clicking on buttons, causing a pop-up box to prompt them for the new information.
You do NOT have to do the same thing as the above example – but you must follow the listed requirements.
Hint: Use the functions provided in the starter code to create, read, and delete cookies.
a. If a cookie is not present, the message “No cookie present” is displayed to the user in the browser
b. If a cookie is present, and your script finds a “fraud match” (the value was found in the fraud_values.txt file), the program should display to the user “The value XXX indicates a fraud!!”, where XXX is replaced by the cookie value.
c. If a cookie is present, but your script finds no “fraud match” (the value was NOT found in the fraud_values.txt file), the program should display to the user “The value XXX does not indicate a fraud. Congratulations!” where XXX is replaced by the cookie value.
d. Your program should work for any number of values in fraud_values.txt, not just on the sample file you created.
Test your program by fetching the URL http://intranet.cs.usna.edu/~mXXXXXX/Lab09/cookie_perl.pl
a. add a link to Lab09/cookie_js.html to your default.htm page
b. add a link to Lab09/cookie_perl.pl to your default.htm page
c. on your coversheet, explain to the instructor what cookie value is detected as being a fraud match and what cookie value is not a fraud match.
4. Install Perl on your Bancroft computer:
a. Download and install Perl from http://www.activestate.com/activeperl?gclid=CNOL56iRqrMCFdKd4AodJ2YA4A (free community edition)
b. Make a test file perltest.pl and save it on your C drive. This file should have the following, where you replace XXXXXX with your name:
print "Perl runs on XXXXXX's computer -- woo-hoo!\n\n";
print hostname() . ":" . localtime() . "\n";
c. Open a command prompt: To do this on Windows XP, click on the “Start” button at the lower left corner of your screen, pick “Run”, then type “cmd” and hit return. On Windows Vista, or Windows 7 Professional, click on "Start" button at the lower left corner of your screen, then type "cmd" in the "Search" box, and hit return.
d. Go the directory where perltest.pl is (cd C:\ if you saved it directly on your C drive)
f. If you get an error because "perl" is not recognized as a command, you need to specify the entire path to perl. For example, if you installed perl in the perl directory on your C drive, you might need to type at the command prompt:
g. Take a screenshot of the output.
On Windows: Use Alt-PrintScreen to take a screenshot, then paste it somewhere (like in Word).
On Linux: you probably know what to do already. If you must, you can just paste the text and print that.
h. Print out the screenshot and turn it in with your lab.
Your web page must be constructed using Notepad++ or a similar text-only editor. The use of programs such as Microsoft Word, Microsoft Frontpage, DreamWeaver, ColdFusion, Mozilla Composer, etc. will be considered an honor offense.