2000 Midterm 1 (40 points)
CSC 123 - Server-Side Web Programming with Active Server Pages
1. Write a portion of ASP code that would output all the form field values posted to an ASP page. Assume the input form uses the POST method. (3 points)
For Each thing in Request.Form
response.write "Name " & thing & " "
response.write "Value: " & Request.Form(Item) & "<BR>"
2. If the physical path to the root of a webserver’s content is “d:\inetpub\wwwroot\” what will be the output of the following line of ASP code? (2 points)
3. TRUE or FALSE: Assuming the text field MYFIELD was the only field in a form on input.htm that called output.asp, would these three lines of code each output the same results? (2 points)
FALSE – Request.Form(0) is illegal—the collection starts at 1
4. What are the scripting languages included with a default install of Microsoft’s Internet Information Server? Which one is the default scripting language for ASP pages? (2 points)
VBScript and JScript – VBScript is the default
5. Name two intrinsic ASP objects. Identify one method and one property for each object. (2 points)
6. Write a single line of ASP code that generates the currect date as formatted below. (2 points)
Tuesday, October 15, 2000
Or also ok: Response.Write FormatDateTime(date,1)
7. Briefly describe what a deprecated HTML element is. Provide an example. (1 point)
9. When the ASP Request object is used to access an undefined querystring variable, does it: (1 point)
a) Return an error.
b) Return “0”.
c) Return an empty string.
d) Returns an error only if Option Explicit was declared in the page.
10. Review the fragment of text from a HTTP message below – did it come from a client or webserver? (1 point)
HTTP/1.0 200 OK
Date: Wed, 02 Feb 2000 12:01:23 GMT
11. Write a line of ASP code that would return how many values a multi-select SELECT form field named “CATEGORY” passed to the ASP page. (2 points)
12. What is the default page buffering behavior for Internet Information Server 4? (1 point)
13. Write out the URL for a page called “Namechek.asp” that passes a field called “NAME” with the value “John Doe” and a second field called “ZIP” with a value of “99999” in the URL’s querystring. (3 points)
16. Write a SQL statement that lists the name, phone number, and zipcode of all employees working at LocationIDs 4, 6, 7, 11, 16, 25 and 28. Assume the LocationIDs are integers. (2 points)
17. When a SQL query contains fields from more then one table, what syntax is used to show what fields come from what tables. (1 points)
18. EXTRA CREDIT - Write a query to list all of the tasks
assigned to employee #2. Include the employee’s full name, task description,
and starting date. (4 points)
SELECT Employees.FirstName, Employees.LastName, Tasks.TaskDescription, Tasks.StartDate FROM Tasks INNER JOIN (Employees INNER JOIN EmployeesAndTasks ON Employees.EmployeeID = EmployeesAndTasks.EmployeeID) ON Tasks.TaskID = EmployeesAndTasks.TaskID WHERE (((Employees.EmployeeID)=2) AND ((Tasks.Voided)=0))
18. The self-referencing ASP page below is called default.asp. Correct, delete, or add ASP code and HTML markup on this page based on the content discussed in class. (10 points + 2 extra credit points)
<%@ language=VBScript %>
<% option explicit %>
sPgBackGround = "#ffffff"
<title>Midterm Test Page</title>
<meta name=”description” content=”Description of midterm test page”>
<body bgcolor=<% = sPgBackGround %> >
<h1>Midterm Test Page</h1>
Select Case Request.Form("VW")
If LEN(Request.Form("NAME")) = 0 then
Response.Write "<p>You entered " & Request.Form("Name") & "</p>"
Set oBC = Server.CreateObject("MSWC.BrowserType")
Response.Write "<p>You are using the following browser: "
Response.Write oBC.Browser & "</p>"
Set oBC = Nothing
If Request.QueryString("ER") = 1 then
Response.Write "Please re-enter your name"
Response.Write "<form method='POST' action='output.asp'>"
Response.Write "<p>Please enter your name: "
Response.Write "<input type='text' name='NAME'>"
"<input type='submit' value='submit'>"
Response.Write "<input type='hidden' name='VW' value='Out'></p>"
<p>CSC 123 Midterm <a href="mailto:firstname.lastname@example.org">Chris Allen</a><br>
Last Updated: October 5, 2000</p>