Chapter 9: Web Programming and Related Tools

1 / 58
About This Presentation
Title:

Chapter 9: Web Programming and Related Tools

Description:

Chapter 9: Web Programming and Related Tools i-Net+ Guide to the Internet Third Edition Objectives Investigate tools that you can use in developing dynamic Web pages ... – PowerPoint PPT presentation

Number of Views:13
Avg rating:3.0/5.0
Slides: 59
Provided by: Prefer1094

less

Transcript and Presenter's Notes

Title: Chapter 9: Web Programming and Related Tools


1
Chapter 9 Web Programming and Related Tools
  • i-Net Guide to the Internet
  • Third Edition

2
Objectives
  • Investigate tools that you can use in developing
    dynamic Web pages
  • Sample several programming languages used to
    build Web sites
  • Write simple Web page scripts
  • Learn how cookies are used on Web pages

3
Cascading Style Sheets
  • Cascading style sheets (CSS), developed by the
    World Wide Web Consortium (W3C), is a feature of
    HTML that makes it possible to apply consistent
    formatting to the HTML documents in a Web site.
  • CSS helps Web developers separate the design of a
    Web site from the content included in the Web
    site.
  • CSS works by controlling how the information on a
    Web page or entire Web site is displayed.

4
Cascading Style Sheets (Continued)
  • An external style sheet is a text file that
    contains rules for controlling how the browser
    displays a Web page that refers to the style
    sheet.

5
XML (Extensible Markup Language) and XSL
(Extensible Style Language)
  • HTML is a subset of the Standard Generalized
    Markup Language (SGML), which is a standard for
    several markup languages.
  • A markup language has special codes that are
    inserted in a text file to instruct software how
    to display or print the text.
  • A newer markup language standard, called XML
    (Extensible Markup Language), is gaining
    popularity.

6
XML (Extensible Markup Language) and XSL
(Extensible Style Language) (Continued)
  • XML supports the standards of SGML, while adding
    flexibility and power.
  • XML is not concerned about how a Web page looks.
  • Instead, XML is used to define and manage data.
  • Many applications of XML are emerging, one of
    which is XSL (Extensible Style Language).
  • XSL is a style language similar to CSS.

7
XML (Extensible Markup Language) and XSL
(Extensible Style Language) (Continued)
  • An XSL file can contain styles, HTML, and
    pointers to XML files, which contain the data and
    tags.
  • XML uses a file called a document type
    definitions (DTD) file.
  • The DTD file provides a list of the tags,
    attributes, and all entities that can be
    contained in an XML document as well as their
    relationships to each other, and might even
    include how they can be arranged together on the
    page.

8
XHTML (Extensible Hypertext Markup Language)
  • Another application that uses XML is XHTML
    (Extensible Hypertext Markup Language), which
    integrates many of the features of XML into HTML.
  • Although XHTML tags are nearly identical to those
    in simple HTM, XHTML is stricter.
  • Developers must be certain their pages follow all
    the syntax rules of XHTML.

9
XHTML (Extensible Hypertext Markup Language)
(Continued)
  • Pages that do follow the XHTML syntax rules are
    said to be well-formed.
  • XHTML is case sensitive, which means that all
    tags must be lowercase.
  • In XHTML, attributes must always be enclosed in
    quotation marks.

10
Introduction to Programming
  • A program is a list of instructions that are
    executed by an operating system or other
    software.
  • Sometimes, the program is written into a text
    file called a source file and is then assembled
    into a coded binary format called object code.
  • Next, the object code is combined with utilities
    that it needs and is then converted and stored
    into an executable file, so named because it is
    executed by the operating system.

11
Introduction to Programming (Continued)
  • Compiling is the process of translating the
    programming code, which a human can understand,
    into binary code, which the computer can
    understand.

12
Introduction to Programming (Continued)
  • Scripts and macros are two types of programs that
    generally do not need to be compiled.
  • These types of programs are sometimes very short,
    containing a list of instructions for performing
    a task, making decisions based on input, and
    producing output.
  • Web pages that can change their content are
    called dynamic Web pages or dynamic HTML (DHTML).
  • Web pages that do not change their content are
    called static Web pages.

13
Two Kinds of Programs
  • A program executed on the server is called a
    server-side script or server-side program.
  • A script executed on the client computer is
    called a client-side script or client-side
    program.

14
Basic Programming Concepts
  • A programming protocol is a set of rules or
    standards by which programs interact with the
    outside world.
  • A programming language, on the other hand, is a
    set of words or codes that are used to write a
    program.
  • A command is an order to perform an action, such
    as to get a file.
  • An argument customizes the action that is stated
    in the command.

15
Basic Programming Concepts (Continued)
  • Commands and their arguments are similar to tags
    and their attributes in HTML.

16
Objects
  • An object is a small program that performs a
    specific task.
  • It is like a middleman who manages the interface
    between the program and some other entity.
  • Objects can be written in several different
    programming languages and can run on a variety of
    operating systems.

17
Objects (Continued)
  • The CORBA (Common Object Request Broker
    Architecture) standard allows objects to
    communicate with each other regardless of the
    language in which they were written or the
    operating system on which they run.
  • To use CORBA, both client and server must be
    running an ORB (Object Request Broker).

18
Objects (Continued)
  • A dynamic link library (DLL) is a library of
    objects used by other programs to perform a
    specific task or group of related tasks.
  • DLLs enable many applications to share the same
    objects easily.
  • DLLs ease the process of upgrading or adding bug
    fixes to an operating system.

19
Functions
  • A function is a segment of programming code that
    can be executed out of order from the main list
    of commands on an as-needed basis.
  • Both objects and functions perform a task off to
    the side of the main flow of the program.
  • The difference between an object and a function
    is that an object is external to the program and
    can even be written in a different programming
    language, but a function is programming code
    included in the program.

20
Functions (Continued)
21
Survey of Programming Languages Used on the
Internet
  • Languages have evolved over the past several
    decades based on changing needs and competition
    among manufacturers.
  • Because programming on the Internet has become
    popular, much attention has been given to
    improving programming languages.
  • As a result, some languages have already been
    through several versions, with each version
    gaining increased Internet functionality.
  • Table 9-1 on page 559 lists the programming
    protocols and languages used on the Web.

22
Programming Protocols
  • Keep in mind that a language can use more than
    one protocol and a protocol can be used by
    several languages.
  • Analogies include addressing an envelope and
    writing a business letter.
  • You use one protocol for addressing envelopes and
    another protocol for writing a business letter.
  • Each can be done in several languages (English,
    Spanish, and so forth).

23
CGI (Common Gateway Interface)
  • The first, and still a very popular, protocol for
    a program or script for interacting with a Web
    server is CGI (Common Gateway Interface), which
    originally was developed for use on UNIX
    computers.
  • When you use CGI, the URL points to a program
    file on the Web server.
  • The file is an executable binary file that is
    loaded and executed by the Web server when a
    browser requests that URL.

24
CGI (Common Gateway Interface) (Continued)
  • The program then builds a Web page that can be
    sent to the browser.

25
ISAPI (Internet Server Application Programming
Interface)
  • Another protocol is ISAPI (Internet Server
    Application Programming Interface), which was
    originally developed by Microsoft for use on
    Windows NT servers that were using Microsoft Web
    server software, Internet Information Server
    (IIS).
  • The fundamental difference between a CGI program
    and an ISAPI program is the way the Web server
    relates to both.

26
ISAPI (Internet Server Application Programming
Interface) (Continued)
  • First, remember that a Web server is an
    executable program.
  • With ISAPI, there is a lot of interaction because
    the Web server relates to the ISAPI program as
    its object or DLL.
  • Even though they are separate entities, each
    depends on the other for successful execution.

27
Active Server Pages (ASP)
  • Active Server Pages (ASP) technology by Microsoft
    is another step in the development of easier and
    more powerful ways to handle server-side
    programming.
  • ASP allows you to write a Web page with one or
    more scripts on the page.
  • The server executes the ASP script that uses the
    ISAPI method to call DLLs to do some of the work
    of customizing the Web page based on information
    sent from the browser and information about the
    server environment.

28
Active Server Pages (ASP) (Continued)
  • After the script has finished customizing the
    page, the Web server sends it to the browser.

29
Java Server Pages (JSP)
  • Sun Microsystems has developed Java Server Pages
    (JSP), which is a protocol similar to, and a
    competitor of, Microsoft Active Server Pages.
  • Java Server Pages can be used to include Java
    programming in HTML on a Web page.
  • Java is a programming language developed by Sun
    Microsystems from C.

30
Java Server Pages (JSP) (Continued)
  • The short segments of Java commands inserted
    inside the HTML Web page by JSP are called Java
    servlets, which are small Java programs that run
    on the server.
  • A JavaBean is a small Java object that works as a
    reusable component in many different situations.

31
SAPI and JSAPI
  • Web sites also provide competing technologies for
    speech recognition.
  • Microsoft offers Speech Application Programming
    Interface (SAPI) and Sun offers Java Speech API
    (JSAPI).
  • In addition, Sun has developed a markup language
    called Java Speech Markup Language (JSML) that
    uses JSAPI.

32
Server-Side Includes (SSI)
  • Server-Side Include (SSI) is a simple, one-line
    form of server-side scripting. It has own
    protocols that allow you to use variable values,
    which can be included in the HTML code before it
    is sent to the browser.
  • SSI lets you include a line in the HTML file that
    indicates that a variable value needs to be
    entered before the file is sent to the browser.

33
Programming Languages Used by Server and Client
  • Many programming languages can use either the CGI
    or ISAPI specifications.
  • ASP can be used by only three scripting
    languagesVBScript, PerlScript, and
    JavaScriptand SSI is limited to a few HTML tags.

34
Perl
  • Perl (Practical Extraction and Report Language)
    originally was written for shell scripts for the
    UNIX operating system.
  • In certain situations, Perl can be used on the
    client.
  • Netscape Navigator supports a Perl plug-in that
    allows it to run some Perl scripts and applets
    downloaded from Web sites.

35
C and C
  • C is a popular programming language developed in
    1972 by Bell Laboratories and later standardized
    by the American National Standards Institute
    (ANSI).
  • The language is compiled, meaning that the file
    containing the original list of commands is input
    into another program to generate a binary
    encrypted file that becomes the executable file.
  • This file customarily has an .exe file extension.

36
C and C (Continued)
  • C is an updated evolution of C that uses an
    object-oriented approach to programming.
  • C is available on most operating system
    platforms, including UNIX, Windows, and
    Macintosh.
  • The C language provides many objects and can
    make use of other objects provided by the
    operating system.

37
Java
  • Java is another object-oriented language that was
    developed by Sun Microsystems.
  • Small Java programs can be downloaded from a Web
    server and executed by a Web browser if the
    browser is capable of interpreting Java code.
  • These small Java programs are called Java applets.

38
PHP
  • PHP (Hypertext Preprocessor) is a scripting
    language originally developed by the Apache
    Software Foundation for the Apache Web Server on
    a UNIX platform, although it has been ported to
    other Web servers and operating systems.
  • It can relate to a Web server using the CGI
    protocol, is easy to learn and use, and is free.

39
Visual Basic
  • Visual Basic (VB), by Microsoft, is a very
    popular language because it is relatively easy to
    learn and, because it is written by Microsoft,
    interacts well with Windows operating systems.
  • Just like C and C, Visual Basic is a compiled
    language - the program is an executable binary
    file.
  • Visual Basic can use DLLs effectively and is an
    object-oriented language.

40
VBScript, PerlScript, JavaScript, and JScript
  • VBScript is a subset of Visual Basic for
    Applications, which is a subset of Visual Basic.
  • VBScript is the default scripting language of
    ASP.
  • PerlScript is an off-shoot of and is similar to
    Perl - it uses some of the same code and
    functions.
  • JavaScript, developed by Netscape for use with
    Netscape Navigator, resembles Java, but is not a
    subset of Java in the way that VBScript is a
    subset of Visual Basic.

41
VBScript, PerlScript, JavaScript, and Jscript
(Continued)
  • JavaScript is interpreted by most browsers and is
    the scripting language of choice if you want to
    serve the most Internet users.
  • To compete with JavaScript, Microsoft developed a
    similar scripting language called Jscript, but
    there are slight inconsistencies between the
    scripting languages and the way Netscape
    Navigator and Internet Explorer interpret each.
  • The new hybrid version of the scripting language
    is called ECMAScript.

42
Learning to Use Scripts
  • All you need to execute a client-side script is a
    browser therefore, a beginner can easily
    practice client-side scripting.
  • Learning to use server-side scripts requires a
    Web server to interpret the script.
  • For an SSI or ASP script, you must type the
    script into the Web page, publish the Web page to
    the server, and then use your browser to access
    the page.

43
Learning to Use Scripts (Continued)
  • When you want to insert scripts on a Web page,
    you must include tags to mark the beginning and
    end of the script.

44
Learning to Use Scripts (Continued)
45
Including the Date on a Web Page
  • In the JavaScript example listed on page 570 and
    shown in Figure 9-22, the script retrieves and
    displays the system date.

46
Adding a Button to a Web Page
  • The next example introduces HTML commands that
    add a button to the Web page.
  • When a user clicks the button, a message appears
    in a box.
  • JavaScript commands are used to create the box
    and its message.
  • The program uses the onClick command, which calls
    a specific function when the button is clicked.

47
Adding a Button to a Web Page (Continued)
48
Creating a Script that Checks for Errors in User
Input
  • In the example on page 574 of client-side
    scripting, you see how a script can validate data
    before the data is sent to the server for
    processing.
  • Make sure to validate data so bad data is not
    accepted when a user clicks the Send button.
  • This Web page displays a message to the user and
    invites the user to enter her name and e-mail
    address, and then click the Send button to send
    the data to the server.

49
Creating a Script that Checks for Errors in User
Input (Continued)
  • The client-side script verifies that the e-mail
    address contains the _at_ symbol.
  • When the user enters correct data in the form on
    the errorchk.htm Web page, the form on the page
    sends the data to another Web page on the server.

50
Server-Side Scripting
  • One important job that can be performed by
    server-side scripts is maintaining a conversation
    between a Web browser and a Web server.
  • A Web server keeps no records of previous
    requests from a Web browser or replies to those
    request.

51
Server-Side Scripting (Continued)
  • A dialog between the browser and server-side
    scripts might go something like this
  • The Web server gives a Web page of items offered
    for sale to the browser.
  • The user selects items from a form on the Web
    page.
  • The server receives the URL and formats the Web
    page showing the selected items with a form that
    allows the user to select a shipping method.

52
All About Cookies
  • Cookies are used to
  • Personalize a Web site with the users name or
    other information.
  • Remember what a person has purchased or placed in
    a shopping cart to purchase later.
  • Track Web site activity to see who has visited
    the site and which pages on the site they access.
  • Target marketing efforts based on your interests.

53
Using Cookies
  • A cookie is a shortcut method of tracking
    information about the user without having to
    prompt the user each time the information is
    needed.
  • A cookie can contain coded information that only
    the server that created it can understand.
  • If a cookie is marked as a secure cookie, it is
    only transmitted to the server when a session is
    secured.

54
Using Cookies (Continued)
  • Some people are concerned about privacy and dont
    want cookies stored on a computer.
  • This can be a valid concern when the computer is
    not your own personal computer, such as one at
    work, in a public library, or other public
    location.

55
How Cookies Work
  • A cookie is created when the HTTP header contains
    the command Set-Cookie.
  • Information about the cookie is included in the
    header and a name/value pair contains the data.
  • Later, when the user again requests Web pages
    from the Web site that created the cookie, the
    browser recognizes that it is holding a cookie
    for this Web site and sends the cookie
    information in the HTTP header when requesting
    the page.

56
How Cookies Work (Continued)
57
Summary
  • CSS is used by developers for creating a group of
    Web pages that have consistent formatting
    throughout the entire Web site.
  • Scripts are used on either the server
    (server-side script) or the client (client-side
    script) to customize a Web page.
  • Similar to Active Server Pages, Java Server Pages
    (JSP) is a technology that allows Java
    programming segments to be written into a Web
    page and executed by the server before the page
    is downloaded to the browser.

58
Summary (Continued)
  • One of the first languages to use CGI was Perl,
    which first was used as a UNIX shell scripting
    language by UNIX system administrators.
  • VBScript is a subset of Visual Basic, Jscript is
    the Microsoft look-alike language for Netscapes
    JavaScript.
  • JavaScript resembles Java but is not a subset of
    Java.
Write a Comment
User Comments (0)