CSCI 4900/6900
Web programming
Lecture 1 -- May 16, 2001
Chapter 1 describes
the infrastructure of the World-wide Web. Be sure you understand the meaning
and function of each of the following:
-
host
-
TCP/IP
-
telnet
-
FTP
-
Internet service provider (ISP)
-
hypertext
-
HTML
-
HTTP
-
URL
-
protocol
-
packet
-
hop
-
Internet Protocol (IP)
-
IP address
-
stateless protocol
-
ping
-
tracert
-
Windows TCP-IP client
-
ipconfig
-
Web site and Web server
-
domain name
-
InterNIC and the domain name registry
-
domain registrars
-
Domain Name Service (DNS)
-
network server
-
Web hosting service
-
virtual Web server
-
Web browser and the rendering process
-
HTML tags
-
heading and body sections of a Web page
-
publishing your Web page using FTP
Basic HTML tags -- heading section
-
head
-
title
-
meta
-
link
-
style
-
script
Basic HTML tags -- body section
-
body
-
Paragraph
-
Heading
-
Bold, italic, underline
-
font
-
center
-
horizontal rule
-
image
-
anchor
-
numbered list, unnumbered list, list item
-
table, table row, table data.
-
comment
Refer to the Netscape
documentation for detailed information on these tags. Understand the
fundamental syntax
<tag attribute=value attribute=value...>
used for HTML tags.
Layered protocol model
-
Physical layer -- defines how the hardware communication link works (Ethernet,
telephone modem, DSL, ATM...)
-
Network layer -- software which implements TCP-IP (part of the OS)
-
Application layer -- protocols specific to a particular application and
implemented in the client and server application programs
Request-response protocols
Chapter 2
describes client-side and server-side scripting.
Client-side scripting
-
Script is delivered to the browser from the server
-
Script runs on the browser
-
User can see the script logic
-
Languages: JavaScript, JScript, VBscript
View http://www.visualinterdev.org/ip/samples/chapter2/javawebpage.htm
in both Navigator and IE. In each browser, choose View/Source. You will
find that
-
IE shows the actual page source
Server-side scripting
-
Script runs on the server, using parameters delivered
from the browser
-
HTML is delivered to the browser
-
User cannot see the script logic
-
Languages: ASP, Java (JSP), PHP, Perl, C++, etc.
etc.
Go to http://msdn.microsoft.com/library/default.asp
for Microsoft's version of JavaScript, and http://developer.netscape.com/docs/manuals/js/client/jsguide/index.htm
for Netscape's. We'll examine some of the subtle differences between these
two versions later on.
The Document Object Model
Chapter 3 describes
object-oriented programming, which should be familiar to all of us. Be
sure you recall the basic OO terminology:
-
classes and objects
-
methods and data members
-
instantiaton and constructors
-
inheritance
We'll discuss language properties in the next lecture,
but these are key differences between the scripting languages JavaScript
and VBscript versus the programming languages C++ and Java:
-
Class members don't need to be declared -- just use
them and they exist!
-
Class data members don't need to be typed -- they
are polymorphic
The best way to program with objects is to instantiate
objects which someone else has already built and tested. Here is the Netscape
object heirarchy:
This image is taken from the Netscape documentation at http://developer.netscape.com/docs/manuals/js/client/jsguide/index.htm.
Note that it is essentially identical to the diagram on page 82 of Halata's
book.
Hierarchy in the object model
Very important: in the diagram below, the arrows represent containment.
For example image[] is a member of document,
not a subclass of document. So for example if you had
-
a form named "custDataEntry"
-
a text box named "firstName" inside this form
--then the textbox could be accessed from a script by referring to document.custDataEntry.firstName.
Note that document is a name already -- it
refers to a unique document object which is always present.
Properties and methods of built-in objects
You must refer to the text or the documentation to discover the properties
of these objects. For example, you will find that the value
of a text box is the text which has been entered into the box. Then to
refer to the contents of the text box we just defined, you would use document.custDataEntry.firstName.value.
An important method is the write
method of the document
object. Writing
document.write("Hi Mom! Are we having
fun yet?");
-allows you to insert text into the Web page. This
allows you to control the contents of the page based on conditions which
only become apparent at runtime.
Events and event handlers
Events in the scripting
context are typically user mouse actions, but can also include events such
as the page being loaded. Event handlers
are properties of objects which specify what action you want the object
to take when the event occurs. Delivery of events to objects is handled
by the OS and the application, so your code doesn't have to worry about
this. For example:
<a href="www.cs.uga.edu/~dme"
onMouseOver = "window.status='Go
to Dr. Dans home page';return true">Dr. Dan's home page</a>
defines the onMouseOver
event handler, which is automatically invoked when you move the mouse over
the link. Try it on this link!
Dr.
Dan's home page
You may have noticed that the window status message
changes when you move the mouse over the link, but does not change back
when you move the mouse off! For this you need the onMouseOut
event handler.
The High-level objects
All the objects reward study, but especially the
high-level ones. I recommend Chapter 11 of the Netscape
on-line JavaScript docs listed above. Here
is a quick summary of the capabilities of these objects:
-
Window: change status bar; open new windows; pop up dialog boxes; change
background colors
-
Navigator: determine browser version
-
Location: change window contents to a different document; reload page
-
History: move backwards or forwards in the browser's history list
-
Document: write content to the document; set colors and background; set
title; handle key and mouse events