![]() |
CSCI A348/548
|
Please write your name or username here:
______________________________________________________
Good luck and do well!
Correct answers appear written in blue.
1. What is the primary function of an HTTP server?The primary function of an HTTP server is to service client requests for documents. It waits for HTTP requests and then returns data for each one. An HTTP daemon provides an HTTP service. It allows a server to support client requests for documents. It generates errors when invalid requests are received or when a document cannot be found. The Web server process also generates log files of requests, errors, and other information.2. What is the primary function of a Web browser?
The primary function of a Web browser is to display HTML documents. Although it can be used to view local documents on a hard drive, it is normally used as a client to retrieve documents from an HTTP server. Although browser software has expanded over the past few years to include such services as e-mail and news, its primary function is to format HTML documents for display.3. A web server is which of the following?
Technically, a Web server consists of two pieces: the hardware and the software. The machine itself is often called a Web server, and the HTTP daemon is also known as a Web server. Still you can have 'your web server' running on the same machine as 'my server' thus sharing the hardware resources but not the programs. Choosing the first answer without any qualifications or notes, should give you most of the credit, and you should get full credit if you mentioned that "it needs hardware, just not dedicated hardware" or something to this effect. ,4. A web server can run on just about any type of machine, not just a huge, expensive server.
Although you probably wouldn't want to run your corporate Web site from a server the size of a matchbook, it is possible to run a Web server on even the smallest computers. Even relatively old and slow computers can do a good job of serving Web pages for a small site.5. A browser utilizes which of the following technologies? (Choose all that apply).
The browser only deals with HTTP directly, so that's the main emphasis of this question. It does use a network and talks to a Web server (indirectly). A phone line is not a necessity to use with a browser, but it may be needed to connect to your ISP.6. Which of the following may be a reason for running a Web server on a port other than port 80?
The amount of memory has nothing to do with ports.7. A server can also be a client.
The server machine that runs a Web server might also be used by users to browse the Web, for example. But that only means we can run clients on any hardware. More specifically, your web server could start a CGI script that retrieves some data over the network from another (database) server. Then it produces the output. The result is passed to the Web server which sends it back to the client. Through the CGI script the Web server acted as a client to a third-tier (back-end) server.8. An HTML file contains
An HTML file only contains text; images are not part of the document. The HTML contains tags that reference images (which are subsequently being retrieved by the browser).9. Which of the following types of tools cannot be used to create hypertext documents?
Most graphics (drawing) programs will not output HTML; they only create graphics images. Those images can be used from a hypertext document, however.10. Mime types are important for which of the following reasons?
11. What is the MIME type of an HTML document?
The media type is12. Why is a simple text editor useful to a webmaster?text
, the subtype ishtml
.
13. Which are the three parts of every HTTP transaction?
A request or response line, a header section, and an entity body.__________________________________________________________________A request line is sent as the first line of all HTTP requests. The browser then sends any relevant headers. An entity body is sent only when data other than the headers needs to be sent to the server. A GET method does not usually contain an entity body, but a POST or PUT method usually does.
A response line is sent as the first line of all HTTP responses. The server then sends any relevant headers and the entity body. The entity body is usually the document requested, but it could also be error information if an error occured while trying to retrieve the document.
14. Name the three most widely used request methods.
GET, POST, and HEAD.__________________________________________________________________Currently, these are the most widely used request methods. As new features are added to the HTTP specification, other methods may become more widely used.
15. What is the difference between a HEAD and a GET?
The HEAD method is used to return the header section for a specific document; it does not return the document itself.__________________________________________________________________
16. What header is sent by the server so that the browser can determine what type of content is being returned?
The Content-type:
header indicates
the media type of the data contained in the entity body. The server determines the type of
data by looking at the file extension and referencing the MIME types file. Server scripts
are responsible for properly labelling their output themselves.
__________________________________________________________________ 17. What is the first thing that is passed to the server when an HTTP transaction begins?
The request line is sent first, containing18. The GET method is the only method that retrieves information from the server.
- the request method,
- the requested resource, and
- the protocol version.
The HEAD method is also used to retrieve information from the server, although it doesn't return an entire document, only information about the document.19. To publish files to a Web server, you should have a user account.
You will normally require some type of login and password to be able to put files on the Web server machine. You can get credit for choosing the other answer if you clearly identify under what realistic circumstances you can publish without logging in.20. If the permissions allow it, users can modify other user's files.
Users can give other people permission to modify their files. Be careful.21. What is the difference between an absolute pathname and a relative pathname?
An absolute pathname always starts with the root directory, in most cases a slash or the backslash. It specifies the exact location of a file in the file system. A relative pathname is used to specify a file with regard to the current directory. A relative pathname does not start with a slash; it can start with a directory name (including dot-dot) or a filename.__________________________________________________________________
22. Which of the following are absolute paths? (Check all that apply).
23. Which of the following are relative paths? (Check all that apply).
24. Which of the following is a document root directory?
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?
26. Filenames are not important because users will always be accessing your site through Web pages, not by typing in filenames directly.
27. Directories are limited to the number of files they can contain, so you should put only a few files in each directory.
28. To access a file named "
A+WeirD&Filename.html
" over the web you need to refer to it as:
29. The filename
MyFile.html
is the same as myfile.html
on a Unix server.
30. What features are attributed to the Apache web server? (Choose all that apply)
It currently uses text-based configuration files and it's free.31. When testing Web servers, only a single server may be set up on a machine.
32. Free Web server software is not good enough to run Enterprise-class Web servers.
Apache is used on many large sites.33. What is CGI?
34. Forms are part of CGI.
35. Forms are the only way that queries can be sent to a CGI program.
36. What is the benefit of using JavaScript code in an HTML document?
Client-side scripting languages such as JavaScript are tightly integrated into the browser. [...] A server-side program cannot do anything with the browser directly; [...]__________________________________________________________________If a JavaScript program is written to respond to user interaction, it can provide very quick responses. [...]
Although there is no limit to the size of JavaScript programs, it is usually a good idea to keep them short. A page with an excessive amount of JavaScript code may take longer to load. Maintaining pages of JavaScript code can become a nightmare; design your pages and write your code with maintenance in mind.
Consider the following JavaScript code:
Assume it's part of an HTML file, and is properly included in it withfunction a(x, y) { return x + y; } function b(x, y) { return x * y; } // a = b; document.write(a(a(3, 4), b(3, 4)));
<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:
What will the browser display when you load the page in it?function a(x, y) { return y(x, x); } function b(x, y) { return x - y; } document.write(a(b(2, 4), b));
__________________________________________________________________
40. (2 points) How do you find out if your server is running, from the Unix prompt?
__________________________________________________________________ps -ef | grep username | grep httpdOr something to that effect.
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:
Finish<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>
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).
44. What, in your own words, is the difference between the Internet and the World Wide Web (if any)?if ($ENV{REQUEST_METHOD} eq 'GET') { $in = $ENV{QUERY_STRING}; _________________________________ } else { read(STDIN, __$in___, $ENV{CONTENT_LENGTH}); } print "Content-type: text/html\n\n"; @in = split(/&/, $in); _____________________________ foreach $e (@in) { ($name, $value) = split(/=/, $e); $name =~ s/%(..)/chr(hex($1))/ge; __________________________________ $value =~ s/%(..)/chr(hex($1))/ge; print $name, "=(", $value, ")"; }
The Internet is the global network allowing computers of all sizes, from many different computer vendors, running totally different operating systems, to communicate with each other. It operates using the TCP/IP protocol suite, which provides the transport and network layers of Internet operation.__________________________________________________________________The World Wide Web is the most popular Internet application, merging hypertext and internetworking paradigms to allow user access to multimedia data. It operates using the HTTP protocol, which is one of the many application layers of the Internet.
45. (2 points) Briefly explain the event handling mechanism in JavaScript.
__________________________________________________________________
46. (2 points) What is the output of the following simple Perl program?
47. (2 points) What is the output of the following simple Perl program?#!/usr/bin/perl @a = (1, 2, 3, 4); print $#a;
48. (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;
49. (2 points) What is the output of the following simple Perl program?#!/usr/bin/perl $a = "My goodness!"; $a =~ s/(.)/($1)/; print $a;
Note the#!/usr/bin/perl $a = "My goodness!"; $a =~ s/(.)/($1)/g; print $a;
g
at the end in this one! 50. (2 points) What is the output of the following simple Perl program?
51. (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;
52. (2 points) What is the output of the following simple Perl program?#!/usr/bin/perl $a = "12345"; $a =~ s/(..)/$1+1/g; print $a;
Again, note the extra#!/usr/bin/perl $a = "12345"; $a =~ s/(..)/$1+1/ge; print $a;
e
at the end!
For all the programming exercises you can obtain the answers by running the programs.
A348/A548