Download 3382ch02-Exercises

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Beginning Active Server Pages 3.0 - Chapter 2 Exercises
Chapter 2 Exercises
1.
Indicate where a task would best be performed - Server Side Script or Client Side Script
Task
Server Side or Client Side
Check if a birth date entered in a form is actually a date
Parse data from a datastore into a list box
Calculate a price quote using a proprietary formula
Find data that matches a person's membership number
Run code that changes the appearance of the page based on
the location of the mouse
Run code that changes preferences in a member database
depending on a mouse click on a check box
Run code that checks if the required fields of a form have data
2.
Which of the following are correct?
Statement
Browsers send out responses.
A request goes from the server.
A response goes to the browser.
Servers receive requests.
The Response Object holds information coming from the
browser
The Request Object holds information going to the Server
True or False
3.
Which METHOD adds its data to the end of the URL?
4.
Compare and contrast Java, Java Server Pages, Javascript and Jscript.
5.
Which object represents the movement of information from the server to the browser: SERVER,
RESPONSE, or REQUEST
6.
Which METHOD adds its data to the end of the URL?
7.
Research the Date and Time functions (page 945) of the VBScript reference of Appendix D.
Create a page which displays the number of seconds after midnight on the server and then the
number of seconds after midnight on the browser. If your server and browser are on different
CPUs then you will see a difference. If they are on the same machine then you will have to
refresh several times until you see an instance where the browser renders the page tens of
milliseconds after the server creates it.
Beginning Active Server Pages 3.0 - Chapter 2 Exercises
Chapter 2 Exercises Answers
1.
Indicate where a task would best be performed - Server Side Script or Client Side Script
Task
Server
Or
Client
Check if a birth date entered on a form Client
is actually a date
Parse data from a datastore into a list
box
Calculate a price quote using a
proprietary formula
Find data that matches a person's
membership number
Server
Server
Server
Run code that changes the appearance Client
of the page based on the location of the
mouse
Run code that changes preferences in a Server
member database depending on a
mouse click on a check box
Run code that checks if the required
fields of a form have data
2.
Client
It is faster to validate data on the client.
Multiple wrong answers and re-tries
will not require multiple round-trips to
the server
Getting information from a datastore is
almost always done on the server
Formulae kept on the server are more
secure then formulae sent to the browser
In order to do this on the browser you
would have to send all possible answers
to the browsers - a long task.
It would be prohibitively slow to
transmit to the server each mouse
movement for the server to build a new
page.
Database changes are almost always
done with server-side code. The mouse
click on the browser just sets the
parameters that are then sent to the
server.
If your check is just to see if the required
field is empty or not you should do that
on the client and save the time of a
round trip if the check fails.
Which of the following are correct?
Browsers send out responses.
A request goes from the server.
A response goes to the browser.
Servers receive requests.
The Response Object holds information coming
from the browser
The Request Object holds information going to the
Server
3.
Note
No, servers send out responses,
browsers send out requests
No, a request goes from the browser,
servers send out responses
Yes
Yes
No, The Response object holds
information coming from the server.
The Request object holds information
coming from the browser.
Yes
Which METHOD adds its data to the end of the URL?
GET adds to the end of the URL. POST includes the data as part of the HTTP body.
Beginning Active Server Pages 3.0 - Chapter 2 Exercises
4.
Compare and contrast Java, Java Server Pages, Javascript and Jscript.
(this is over-simplified for clarity)
Java is a language used to create applications (usually small) that are sent across the web to be executed on
the client.
Java can run on any machine with a Java-enabled browser.
Java applications should be unable to harm the client.
Much of the processing power is contained in Java Classes that are installed on the client at the time
the browser is installed.
Java Server Pages is a technology similar to ASP in that it allows the building of dynamic pages on the
server by using intrinsic objects and script engines.
JavaScript is a programming language for creating dynamic web pages. Dynamic in this sense means that
pages can change in response to either business situations or to user's actions.
- JavaScript can run at the server or the client.
JScript is a Microsoft implementation of JavaScript.
So all three are the same in that they are programming languages designed for the web.
They differ in:
where they can run (Java on client only, JSP on server only, scripts on server or client).
Java is designed to build whole apps whereas the scripts focus on making one page dynamic.
JSP is a technology containing intrinsic objects and script engines whereas the other three are
programming languages
5.
Which object represents the movement of information from the server to the browser: SERVER,
RESPONSE, or REQUEST
RESPONSE Object.
SERVER object represents the server itself, the REQUEST object represents information from the browser
to the server.
6.
Which METHOD adds its data to the end of the URL?
GET adds to the end of the URL. POST includes the data as part of the HTTP body.
7.
Research the Date and Time functions (page 945) of the VBScript reference of Appendix D.
Create a page which displays the number of seconds after midnight on the server and then the
number of seconds after midnight on the browser.
<%@ Language=VBScript %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>
<H3>Time Comparer</H3>
<HR>
This page was built on the server at
<%
Response.Write Timer()
%>
<HR>
This page was rendered on the browser at
<SCRIPT LANGUAGE=VBSCRIPT>
Document.Write Timer()
</SCRIPT>
</BODY>
</HTML>