Fall 2000 Midterm 1  (40 points)
CSC 123 - Server-Side Web Programming with Active Server Pages

 

Name: _______________________    Student ID#:________________   Child Web: __________

 

 

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>"

Next

 

 

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)

Response.Write Server.MapPath(“/Search/Search.asp”)

 

d:\inetpub\wwwroot\search\search.asp

 

 

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)

Request.Form("MYFIELD")

Request.Form.Item("MYFIELD")

Request.Form(0)

 

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)

Object

Property

Method

 

 

 

 

 

 

 

 

 

 

 

 

 

 

6.  Write a single line of ASP code that generates the currect date as formatted below. (2 points)

                Tuesday, October 15, 2000

 

Response.Write FormatDateTime(#10/15/2000#,1)

Or also ok:  Response.Write FormatDateTime(date,1)

 

7.  Briefly describe what a deprecated HTML element is. Provide an example. (1 point)

 

An HTML element or attribute that has been outdated or replaced with new constructs. Deprecated elements will not be supported in future versions of HTML. HTML clients are not required to support deprecated elements. Examples would include <center>, <bold>, <I>,<font>, etc.

 

8.  Describe briefly how the Browser Capabilities Component is able to determine what browser you are using.  (2 points)

 

BCC reads the HTTP USER_AGENT header sent by the client/browser.

BCC refers to the browscap.ini file on the server to determine the browser and its capabilities.

 

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

Content-Type: text/html

 

Server

 

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)

 

Response.Write Request.Form("CATEGORY").Count

 

 

12.  What is the default page buffering behavior for Internet Information Server 4? (1 point)

 

Buffering is false

 

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)

 

Namecheck.asp?NAME=John+Doe&ZIP=99999

 

14.  Why are self-referencing ASP pages a good programming practice?  (2 points)

 

Code reuse, code maintainability, more efficient caching and retrieval on web server

 

 

ERD

Using the database diagram above, answer the following questions:

 

15.  Write a SQL statement that adds a new record to the employee table using the information below. (2 points)

Name: Bob Jones

Title: President

Email: bob@acme.com
Phone: (916) 543-1234 x123
Location ID: 1


Insert Into Employees (FirstName, LastName, Title, EmailName, WorkPhone, Extension, LocationID, Voided) Values ('Bob','Jones', 'President', 'bob@acme.com', '916-543-1234','x123',1,0)

 

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)

 

SELECT Employees.Firstname, Employees.Lastname, Employees.WorkPhone, Location.ZipCode FROM Employees INNER JOIN Location ON Employee.LocationID = Location.LocationID WHERE (LocationID IN (4,6,7,11,16,25,28) AND Employees.Voided = 0 ) ORDER BY Employees.LastName, Employees.Firstname

 

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)

 

Dot or .

 

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 %>

 

<%

dim oBC

dim sPgBackGround

 

sPgBackGround = "#ffffff"

 

%>

 

<html>

 

<head>

 

<title>Midterm Test Page</title>

 

<meta name=”description” content=”Description of midterm test page”>

 

</head>

 

<body bgcolor=<% = sPgBackGround %> >

 

<h1>Midterm Test Page</h1>

 

<%

 

Select Case Request.Form("VW")

Case "Out"

              If LEN(Request.Form("NAME")) = 0 then

                     Response.Redirect ("default.asp?ER=1")

              Else

                     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

              End If

 

 

       Case Else

              If Request.QueryString("ER") = 1 then

                     Response.Write "Please re-enter your name"

              End If

              Response.Write "<form method='POST' action='output.asp'>"

Response.Write "<p>Please enter your name:&nbsp;"

Response.Write "<input type='text' name='NAME'>"

Response.Write "<input type='submit' value='submit'>"
Response.Write "<input type=
'hidden' name='VW' value='Out'></p>"

Response.Write "</form>"

 

End Select

 

%>

<hr>

<p>CSC 123 Midterm <a href="mailto:chris@valtara.com">Chris Allen</a><br>

Last Updated: October 5, 2000</p>

</body>

</html>