CSCI A348/A548

Final Examination

Second Summer 2002



1. What is the primary function of an HTTP server?
to display HTML documents
to process HTTP requests
to run CGI scripts
all of the above
none of the above
2. What is the primary function of a Web browser?
to send e-mail
to read news
to display HTML documents
all of the above
to run CGI scripts
none of the above
3. A web server is which of the following?
software hardware both
4. A web server can run on just about any type of machine, not just a huge, expensive server.
true false
5. A browser utilizes which of the following technologies? (Choose all that apply).
A network A Web server A phone line HTTP
6. Which of the following may be a reason for running a Web server on a port other than port 80?
a) You don't have access to port 80 (since you are not root).
b) You are running multiple Web servers on the same machine.
c) You don't have enough memory.
d) Both a) and b).
e) All of the above.
7. A server can also be a client.

true false
8. An HTML file contains
Text Images Both text and images Binary data
9. Which of the following types of tools cannot be used to create hypertext documents?
A simple text editor
A word processing program
An automatic HTML generator
A graphics utility
All of these are capable of creating hypertext documents
10. Mime types are important for which of the following reasons?
They allow the browser and server to communicate
They tell applications what kinds of documents are being sent
They speed the transmission of binary files
FTP uses them to determine how to transfer files
11. What is the MIME type of an HTML document?
html/text
HTML
text/html
text/plain
none of the above
12. Why is a simple text editor useful to a webmaster?
It generates plain text files with no special characters
Text editors are generally available on all platforms
In many cases it's quicker than using a large application
All of the above
A simple text editor is not useful to a webmaster
13. Which are the three parts of every HTTP transaction?

__________________________________________________________________

14. Name the three most widely used request methods.

__________________________________________________________________

15. What is the difference between a HEAD and a GET?

__________________________________________________________________

16. What header is sent by the server so that the browser can determine what type of content is being returned?

__________________________________________________________________

17. What is the first thing that is passed to the server when an HTTP transaction begins?

The request line
The response line
The entity body
The transaction line
All of the above could be sent first
None of the above could be sent first
18. The GET method is the only method that retrieves information from the server.

true false
19. To publish files to a Web server, you should have a user account.

true false
20. If the permissions allow it, users can modify other user's files.

true false
21. What is the difference between an absolute pathname and a relative pathname?

__________________________________________________________________

22. Which of the following are absolute paths? (Check all that apply).

/usr/local/apache/htdocs/
../support/vortex.html
moose.gif
/etc/passwd
23. Which of the following are relative paths? (Check all that apply).

/export/home/eric1
../images/backgrounds/water.gif
sales/
./sales/
24. Which of the following is a document root directory?

c:\
c:\html_docs
/opt/apache/htdocs
It depends on how the web server is configured
25. Directory indexing allows the Web server to generate a page containing a list of files in a directory automatically if no default document is specified.

Which of the following names have we used in this class for default documents?

index.html
default.html
welcome.html
All of the above
26. Filenames are not important because users will always be accessing your site through Web pages, not by typing in filenames directly.
true false
27. Directories are limited to the number of files they can contain, so you should put only a few files in each directory.
true false
28. To access a file named "A+WeirD&Filename.html" over the web you need to refer to it as:
A+WeirD&Filename.html
A%2BWeirD%26Filename.html
None of the above
This file cannot be accessed over the web.
29. The filename MyFile.html is the same as myfile.html on a Unix server.

true false
30. What features are attributed to the Apache web server? (Choose all that apply)

Speed
Customization
Easy-to-use GUI configuration
Expensive
31. When testing Web servers, only a single server may be set up on a machine.

true false
32. Free Web server software is not good enough to run Enterprise-class Web servers.

true false
33. What is CGI?
A programming language
An API (Application Programming Interface)
A method for a Web server to communicate with other programs
None of the above
All of the above
34. Forms are part of CGI.
true false
35. Forms are the only way that queries can be sent to a CGI program.

true false
36. What is the benefit of using JavaScript code in an HTML document?

__________________________________________________________________

Consider the following JavaScript code:

function a(x, y) {
  return x + y;
}
function b(x, y) {
  return x * y;
}
// a = b;
document.write(a(a(3, 4), b(3, 4))); 
Assume it's part of an HTML file, and is properly included in it with <SCRIPT> tags in it.

37. (2 points) What will the browser display when you load the page in it.

__________________________________________________________________

38. How does the answer change if you uncomment the line currently commented?

__________________________________________________________________

39. (2 points) Consider the following JavaScript code:

function a(x, y) {  
  return y(x, x);
} 
function b(x, y) {  
  return x - y;
} 
document.write(a(b(2, 4), b)); 
What will the browser display when you load the page in it?

__________________________________________________________________

40. (2 points) How do you find out if your server is running, from the Unix prompt?

__________________________________________________________________

41. (2 points) What's in the httpd.pid file?

__________________________________________________________________

42. (2 points) What's ENV and where did we use it? What does it contain?

__________________________________________________________________

43. (8 points) Here's a form:

<html>
  <body bgcolor=white>
    <form method="POST" action="/cgi-bin/alpha">
      <input type=text name="a"> 
      <input type=text name="c"> 
      <input type="submit" value="Proceed">
    </form>
  </body>
</html>
Finish alpha that prints the values associated with a and b. (Write the code that should go on the three missing lines plus one other spot).
if ($ENV{REQUEST_METHOD} eq 'GET') {

  _________________________________
} else {
  read(STDIN, _______, $ENV{CONTENT_LENGTH});
}

print "Content-type: text/html\n\n";

@in = _____________________________

foreach $e (@in) {
  ($name, $value) = split(/=/, $e);

  __________________________________
  $value =~ s/%(..)/chr(hex($1))/ge;
  print $name, "=(", $value, ")";
}
44. What, in your own words, is the difference between the Internet and the World Wide Web (if any)?

__________________________________________________________________

45. (2 points) Briefly explain the event handling mechanism in JavaScript.

__________________________________________________________________

46. (2 points) What is the output of the following simple Perl program?

#!/usr/bin/perl
@a = (1, 2, 3, 4);
print $#a;
47. (2 points) What is the output of the following simple Perl program?

#!/usr/bin/perl
$a = "There's a tomato in every automaton.";
$a =~ s/tomato/**/g;
print $a;
48. (2 points) What is the output of the following simple Perl program?

#!/usr/bin/perl
$a = "My goodness!"; 
$a =~ s/(.)/($1)/;
print $a;     
49. (2 points) What is the output of the following simple Perl program?

#!/usr/bin/perl
$a = "My goodness!"; 
$a =~ s/(.)/($1)/g;
print $a;     
Note the g at the end in this one!

50. (2 points) What is the output of the following simple Perl program?

#!/usr/bin/perl
$a = "hOoB!y"; 
$a =~ s/(.)(.)/$2$1/g;
print $a;     
51. (2 points) What is the output of the following simple Perl program?

#!/usr/bin/perl
$a = "12345"; 
$a =~ s/(..)/$1+1/g;
print $a;     
52. (2 points) What is the output of the following simple Perl program?

#!/usr/bin/perl
$a = "12345"; 
$a =~ s/(..)/$1+1/ge;
print $a;     
Again, note the extra e at the end!
Last updated on Aug 6, 2002, by Adrian German for A348/A548.