HAPPY BOOKSGIVING
Use code BOOKSGIVING during checkout to save 40%-55% on books and eBooks. Shop now.
Register your product to gain access to bonus material or receive a coupon.
Internet and World Wide Web How to Program, 4e by market leading authors, Harvey M. Deitel and Paul J. Deitel introduces readers with little or no programming experience to the exciting world of Web-Based applications. This book has been substantially revised to reflect today's Web 2.0 rich Internet application-development methodologies. A comprehensive book that covers the fundamentals needed to program on the Internet, this book provides in-depth coverage of introductory programmming principles, various markup languages (XHTML, Dynamic HTML and XML), several scripting languages (JavaScript, PHP, Ruby/Ruby on Rails and Perl); AJAX, web services, Web Servers (IIS and Apache) and relational databases (MySQL/Apache Derby/Java DB) -- all the skills and tools needed to create dynamic Web-based applications. The book contains comprehensive introductions to ASP.NET 2.0 and JavaServer Faces (JSF) and a new chapter on Adobe Flex 2.0. Hundreds of live-code examples of real applications are throughout the book. The examples are downloadable from the Deitel website once registered and logged in and allow readers to run the applications and see and hear the outputs. The book provides instruction on building Ajax-enabled rich Internet applications that enhance the presentation of online content and give web applications the look and feel of desktop applications. The chapter on Web 2.0 and Internet business exposes readers to a wide range of other topics associated with Web 2.0 applications and businesses After mastering the material in this book, readers will be well prepared to build real-world, industrial strength, Web-based applications. For Internet and Web-based computer programmers, and others in organizations and businesses who need to develop their own Websites and pages.
Preface xxi
Part 1: Introduction 1
1 Introduction to Computers and
the Internet 2
1.1 Introduction
1.2 What Is a Computer?
1.3 Computer Organization
1.4 Machine Languages, Assembly Languages
and High-Level Languages
1.5 History of the Internet and World Wide Web
1.6 World Wide Web Consortium (W3C)
1.7 Web 2.0
1.8 Personal, Distributed and Client/Server Computing
1.9 Hardware Trends
1.10 Key Software Trend: Object Technology
1.11 JavaScript: Object-Based Scripting for the Web
1.12 Browser Portability
1.13 C, C++ and Java
1.14 BASIC, Visual Basic, Visual C++, C# and .NET
1.15 Software Technologies
1.16 Notes about Internet& World Wide Web How to Program, 4/e
1.17 Web Resources
2 Web Browser Basics: Internet Explorer
and Firefox 28
2.1 Introduction to the Internet Explorer 7 and Firefox 2 Web Browsers
2.2 Connecting to the Internet
2.3 Internet Explorer 7 and Firefox 2 Features
2.4 Customizing Browser Settings
2.5 Searching the Internet
2.6 Keeping Track of Your Favorite Sites
2.7 File Transfer Protocol (FTP)
2.8 Online Help
Contents
x Contents
2.9 Other Web Browsers
2.10 Wrap-Up
2.11 Web Resources
3 Dive Into®Web 2.0 50
3.1 Introduction
3.2 What Is Web 2.0?
3.3 Search
3.4 Content Networks
3.5 User-Generated Content
3.6 Blogging
3.7 Social Networking
3.8 Social Media
3.9 Tagging
3.10 Social Bookmarking
3.11 Software Development
3.12 Rich Internet Applications (RIAs)
3.13 Web Services, Mashups, Widgets and Gadgets
3.14 Location-Based Services
3.15 XML, RSS, Atom, JSON and VoIP
3.16 Web 2.0 Monetization Models
3.17 Web 2.0 Business Models
3.18 Future of the Web
3.19 Wrap-Up
3.20 Where to Go for More Web 2.0 Information
3.21 Web 2.0 Bibliography
3.22 Web 2.0 Glossary
Part 2: The Ajax Client 117
4 Introduction to XHTML 118
4.1 Introduction
4.2 Editing XHTML
4.3 First XHTML Example
4.4 W3C XHTML Validation Service
4.5 Headings
4.6 Linking
4.7 Images
4.8 Special Characters and Horizontal Rules
4.9 Lists
4.10 Tables
4.11 Forms
4.12 Internal Linking
4.13 meta Elements
4.14 Wrap-Up
4.15 Web Resources
Contents xi
5 Cascading Style Sheets™ (CSS) 159
5.1 Introduction
5.2 Inline Styles
5.3 Embedded Style Sheets
5.4 Conflicting Styles
5.5 Linking External Style Sheets
5.6 Positioning Elements
5.7 Backgrounds
5.8 Element Dimensions
5.9 Box Model and Text Flow
5.10 Media Types
5.11 Building a CSS Drop-Down Menu
5.12 User Style Sheets
5.13 CSS 3
5.14 Wrap-Up
5.15 Web Resources
6 JavaScript: Introduction to Scripting 197
6.1 Introduction
6.2 Simple Program: Displaying a Line of Text in a Web Page
6.3 Modifying Our First Program
6.4 Obtaining User Input with prompt Dialogs
6.4.1 Dynamic Welcome Page
6.4.2 Adding Integers
6.5 Memory Concepts
6.6 Arithmetic
6.7 Decision Making: Equality and Relational Operators
6.8 Wrap-Up
6.9 Web Resources
7 JavaScript: Control Statements I 234
7.1 Introduction
7.2 Algorithms
7.3 Pseudocode
7.4 Control Structures
7.5 if Selection Statement
7.6 if…else Selection Statement
7.7 while Repetition Statement
7.8 Formulating Algorithms: Counter-Controlled Repetition
7.9 Formulating Algorithms: Sentinel-Controlled Repetition
7.10 Formulating Algorithms: Nested Control Statements
7.11 Assignment Operators
7.12 Increment and Decrement Operators
7.13 Wrap-Up
7.14 Web Resources
xii Contents
8 JavaScript: Control Statements II 278
8.1 Introduction
8.2 Essentials of Counter-Controlled Repetition
8.3 for Repetition Statement
8.4 Examples Using the for Statement
8.5 switch Multiple-Selection Statement
8.6 do…while Repetition Statement
8.7 break and continue Statements
8.8 Labeled break and continue Statements
8.9 Logical Operators
8.10 Summary of Structured Programming
8.11 Wrap-Up
8.12 Web Resources
9 JavaScript: Functions 321
9.1 Introduction
9.2 ProgramModules in JavaScript
9.3 Programmer-Defined Functions
9.4 Function Definitions
9.5 Random Number Generation
9.6 Example: Game of Chance
9.7 Another Example: Random Image Generator
9.8 Scope Rules
9.9 JavaScript Global Functions
9.10 Recursion
9.11 Recursion vs. Iteration
9.12 Wrap-Up
9.13 Web Resources
10 JavaScript: Arrays 362
10.1 Introduction
10.2 Arrays
10.3 Declaring and Allocating Arrays
10.4 Examples Using Arrays
10.5 Random Image Generator Using Arrays
10.6 References and Reference Parameters
10.7 Passing Arrays to Functions
10.8 Sorting Arrays
10.9 Searching Arrays: Linear Search and Binary Search
10.10 Multidimensional Arrays
10.11 Building an Online Quiz
10.12 Wrap-Up
10.13 Web Resources
11 JavaScript: Objects 403
11.1 Introduction
Contents xiii
11.2 Introduction to Object Technology
11.3 Math Object
11.4 String Object
11.4.1 Fundamentals of Characters and Strings
11.4.2 Methods of the String Object
11.4.3 Character-Processing Methods
11.4.4 Searching Methods
11.4.5 Splitting Strings and Obtaining Substrings
11.4.6 XHTML Markup Methods
11.5 Date Object
11.6 Boolean and Number Objects
11.7 document Object
11.8 window Object
11.9 Using Cookies
11.10 Final JavaScript Example
11.11 Using JSON to Represent Objects
11.12 Wrap-Up
11.13 Web Resources
12 Document Object Model (DOM):
Objects and Collections 458
12.1 Introduction
12.2 Modeling a Document: DOM Nodes and Trees
12.3 Traversing and Modifying a DOM Tree
12.4 DOM Collections
12.5 Dynamic Styles
12.6 Summary of the DOM Objects and Collections
12.7 Wrap-Up
12.8 Web Resources
13 JavaScript: Events 487
13.1 Introduction
13.2 Registering Event Handlers
13.3 Event on load
13.4 Event on mouse move, the event Object and this
13.5 Rollovers with on mouse over and on mouse out
13.6 Form Processing with on focus and on blur
13.7 More Form Processing with on submit and on reset
13.8 Event Bubbling
13.9 More Events
13.10 Wrap-Up
13.11 Web Resources
14 XML and RSS 515
14.1 Introduction
14.2 XML Basics
xiv Contents
14.3 Structuring Data
14.4 XML Namespaces
14.5 Document Type Definitions (DTDs)
14.6 W3C XML Schema Documents
14.7 XML Vocabularies
14.7.1 MathML™
14.7.2 Other Markup Languages
14.8 Extensible Stylesheet Language and XSL Transformations
14.9 Document Object Model (DOM)
14.10 RSS
14.11 Wrap-Up
14.12 Web Resources
15 Ajax-Enabled Rich Internet Applications 588
15.1 Introduction
15.2 Traditional Web Applications vs. Ajax Applications
15.3 Rich Internet Applications (RIAs) with Ajax
15.4 History of Ajax
15.5 “Raw” Ajax Example Using the XMLHttpRequest Object
15.6 Using XML and the DOM
15.7 Creating a Full-Scale Ajax-Enabled Application
15.8 Dojo Toolkit
15.9 Wrap-Up
15.10 Web Resources
Part 3: Rich Internet Application
Client Technologies 635
16 Adobe® Flash® CS3 636
16.1 Introduction
16.2 Flash Movie Development
16.3 Learning Flash with Hands-On Examples
16.3.1 Creating a Shape with the Oval Tool
16.3.2 Adding Text to a Button
16.3.3 Converting a Shape into a Symbol
16.3.4 Editing Button Symbols
16.3.5 Adding Keyframes
16.3.6 Adding Sound to a Button
16.3.7 Verifying Changes with Test Movie
16.3.8 Adding Layers to a Movie
16.3.9 Animating Text with Tweening
16.3.10 Adding a Text Field
16.3.11 Adding ActionScript
16.4 Publishing Your Flash Movie
Contents xv
16.5 Creating Special Effects with Flash
16.5.1 Importing and Manipulating Bitmaps
16.5.2 Creating an Advertisement Banner with Masking
16.5.3 Adding Online Help to Forms
16.6 Creating a Website Splash Screen
16.7 ActionScript
16.8 Wrap-Up
16.9 Web Resources
17 Adobe® Flash® CS3: Building an
Interactive Game 683
17.1 Introduction
17.2 Object-Oriented Programming
17.3 Objects in Flash
17.4 Cannon Game: Preliminary Instructions and Notes
17.5 Adding a Start Button
17.6 Creating Moving Objects
17.7 Adding the Rotating Cannon
17.8 Adding the Cannonball
17.9 Adding Sound and Text Objects to the Movie
17.10 Adding the Time Counter
17.11 Detecting a Miss
17.12 Adding Collision Detection
17.13 Finishing the Game
17.14 ActionScript 3.0 Elements Introduced in This Chapter
18 Adobe® Flex™ 2 and Rich Internet
Applications 711
18.1 Introduction
18.2 Flex PlatformOverview
18.3 Creating a Simple User Interface
18.4 Accessing XML Data from Your Application
18.5 Interacting with Server-Side Applications
18.6 Customizing Your User Interface
18.7 Creating Charts and Graphs
18.8 Connection-Independent RIAs on the Desktop:
Adobe Integrated Runtime (AIR)
18.9 Flex 3 Beta
18.10 Wrap-Up
18.11 Web Resources
19 Microsoft® Silverlight™ and Rich Internet
Applications 770
19.1 Introduction
19.2 PlatformOverview
xvi Contents
19.3 Silverlight 1.0 Installation and Overview
19.4 Creating a Movie Viewer for Silverlight 1.0
19.4.1 Creating a User Interface In XAML Using Expression Blend
19.4.2 Using Storyboards
19.4.3 Creating Controls
19.4.4 Using JavaScript for Event Handling and DOM Manipulation
19.6 Silverlight Streaming
19.7 Silverlight 1.1 Installation and Overview
19.8 Creating a Cover Viewer for Silverlight 1.1 Alpha
19.9 Building an Application with Third-Party Controls
19.10 Consuming a Web Service
19.10.1 Consuming the Huge Integer Web Service
19.11 Silver light Demos, Games and Web Resources
19.12 Wrap-Up
20 Adobe® Dreamweaver® CS3 830
20.1 Introduction
20.2 Adobe Dreamweaver CS3
20.3 Text Styles
20.4 Images and Links
20.5 Symbols and Lines
20.6 Tables
20.7 Forms
20.8 Scripting in Dreamweaver
20.9 Spry Framework for Creating Ajax Applications
20.10 Site Management
20.11 Wrap-Up
20.12 Web Resources
Part 4: Rich Internet Application
Server Technologies 857
21 Web Servers (IIS and Apache) 858
21.1 Introduction
21.2 HTTP Transactions
21.3 Multitier Application Architecture
21.4 Client-Side Scripting versus Server-Side Scripting
21.5 Accessing Web Servers
21.6 Microsoft Internet Information Services (IIS)
21.6.1 Microsoft Internet Information Services (IIS) 5.1 and 6.0
21.6.2 Microsoft Internet Information Services (IIS) 7.0
21.7 Apache HTTP Server
21.8 Requesting Documents
21.9 Web Resources
Contents xvii
22 Database: SQL, MySQL, ADO.NET 2.0
and Java DB 879
22.1 Introduction
22.2 Relational Databases
22.3 Relational Database Overview: A books Database
22.4 SQL
22.4.1 Basic SELECT Query
22.4.2 WHERE Clause
22.4.3 ORDER BY Clause
22.4.4 Combining Data from Multiple Tables: INNER JOIN
22.4.5 INSERT Statement
22.4.6 UPDATE Statement
22.4.7 DELETE Statement
22.5 MySQL
22.6 Instructions for Installing MySQL
22.7 Instructions for Setting Up a MySQL User Account
22.8 Creating a Database in MySQL
22.9 ADO.NET Object Model
22.10 Java DB/Apache Derby
22.11 Wrap-Up
22.12 Web Resources
23 PHP 905
23.1 Introduction
23.2 PHP Basics
23.3 String Processing and Regular Expressions
23.3.1 Comparing Strings
23.3.2 Regular Expressions
23.4 FormProcessing and Business Logic
23.5 Connecting to a Database
23.6 Using Cookies
23.7 Dynamic Content
23.8 Operator Precedence Chart
23.9 Wrap-Up
23.10 Web Resources
24 Ruby on Rails 956
24.1 Introduction
24.2 Ruby
24.3 Rails Framework
24.4 Action Controller and ActionView
24.5 A Database-Driven Web Application
24.6 Case Study: Message Forum
24.6.1 Logging In and Logging Out
24.6.2 Embellishing the Models
xviii Contents
24.6.3 Generating Scaffold Code
24.6.4 ForumController and ForumViews
24.6.5 Message Controller and Message Views
24.6.6 Ajax-Enabled Rails Applications
24.7 Script.aculo.us
24.8 Wrap-Up
24.9 Web Resources
25 ASP.NET 2.0 and ASP.NET Ajax 1009
25.1 Introduction
25.2 Creating and Running a Simple Web Form Example
25.2.1 Examining an ASPX File
25.2.2 Examining a Code-Behind File
25.2.3 Relationship Between an ASPX File and a Code-Behind File
25.2.4 How the Code in an ASP.NET Web Page Executes
25.2.5 Examining the XHTML Generated by an ASP.NET Application
25.2.6 Building an ASP.NET Web Application
25.3 Web Controls
25.3.1 Text and Graphics Controls
25.3.2 AdRotator Control
25.3.3 Validation Controls
25.4 Session Tracking
25.4.1 Cookies
25.4.2 Session Tracking with Http Session State
25.5 Case Study: Connecting to a Database in ASP.NET
25.5.1 Building a Web Form That Displays Data from a Database
25.5.2 Modifying the Code-Behind File for the Guestbook Application
25.6 Case Study: Secure Books Database Application
25.6.1 Examining the Completed Secure Books Database Application
25.6.2 Creating the Secure Books Database Application
25.7 ASP.NET Ajax
25.8 Wrap-Up
25.9 Web Resources
26 JavaServer™ FacesWeb Applications 1118
26.1 Introduction 1119
26.2 Java Web Technologies
26.2.1 Servlets
26.2.2 JavaServer Pages
26.2.3 JavaServer Faces
26.2.4 Web Technologies in Netbeans
26.3 Creating and Running a Simple Application in Netbeans
26.3.1 Examining a JSP File 1124
26.3.2 Examining a Page Bean File
26.3.3 Event-Processing Life Cycle
26.3.4 Relationship Between the JSP and Page Bean Files
Contents xix
26.3.5 Examining the XHTML Generated by a Java Web Application
26.3.6 Building a Web Application in Netbeans
26.4 JSF Components
26.4.1 Text and Graphics Components
26.4.2 Validation Using Validator Components and Custom Validators
26.5 Session Tracking
26.5.1 Cookies
26.5.2 Session Tracking with the Session Bean Object
26.6 Wrap-Up
26.7 Web Resources
27 Ajax-Enabled JavaServer™ Faces
Web Applications 1187
27.1 Introduction
27.2 Accessing Databases in Web Applications
27.2.1 Building a Web Application That Displays Data from a Database
27.2.2 Modifying the Page Bean File for the Address Book Application
27.3 Ajax-Enabled JSF Components
27.4 AutoComplete Text Field and Virtual Forms
27.4.1 Configuring Virtual Forms
27.4.2 JSP File with Virtual Forms and an AutoComplete Text Field
27.4.3 Providing Suggestions for an AutoComplete Text Field
27.5 Google Maps Map Viewer Component
27.5.1 Obtaining a Google Maps API Key
27.5.2 Adding a Map Viewer Component to a Page
27.5.3 JSP File with a Map Viewer Component
27.5.4 Page Bean That Displays a Map in the Map Viewer Component
27.6 Wrap-Up
27.7 Web Resources
28 Web Services 1225
28.1 Introduction
28.2 Java Web Services Basics
28.3 Creating, Publishing, Testing and Describing a Web Service
28.3.1 Creating a Web Application Project and Adding a Web
Service Class in Netbeans
28.3.2 Defining the HugeInteger Web Service in Netbeans
28.3.3 Publishing the HugeInteger Web Service from Netbeans
28.3.4 Testing the HugeInteger Web Service with Sun Java System
Application Server’s Tester Web page
28.3.5 Describing a Web Service with the Web Service
Description Language (WSDL)
28.4 Consuming a Web Service
28.4.1 Creating a Client in Netbeans to Consume the HugeInteger
Web Service
28.4.2 Consuming the HugeInteger Web Service
xx Contents
28.5 SOAP
28.6 Session Tracking in Web Services
28.6.1 Creating a Blackjack Web Service
28.6.2 Consuming the Blackjack Web Service
28.7 Consuming a Database-Driven Web Service from a Web Application
28.7.1 Configuring Java DB in Netbeans and Creating the
Reservation Database
28.7.2 Creating a Web Application to Interact with the
Reservation Web Service
28.8 Passing an Object of a User-Defined Type to a Web Service
28.9 REST-Based Web Services in ASP.NET
28.9.1 REST-Based Web Service Functionality
28.9.2 Creating an ASP.NET REST-Based Web Service
28.9.3 Adding Data Components to a Web Service
28.10 Wrap-Up
28.11 Web Resources
Part 5: Appendices 1303
A XHTML Special Characters 1304
B XHTML Colors 1305
C JavaScript Operator Precedence Chart 1308
D ASCII Character Set 1310
E Number Systems 1311
E.1 Introduction 1312
E.2 Abbreviating Binary Numbers as Octal and Hexadecimal Numbers
E.3 Converting Octal and Hexadecimal Numbers to Binary Numbers
E.4 Converting from Binary, Octal or Hexadecimal to Decimal
E.5 Converting from Decimal to Binary, Octal or Hexadecimal
E.6 Negative Binary Numbers: Two’s Complement Notation
F Unicode® 1325
F.1 Introduction
F.2 Unicode Transformation Formats
F.3 Characters and Glyphs
F.4 Advantages/Disadvantages of Unicode
F.5 Unicode Consortium’s Website
F.6 Using Unicode
F.7 Character Ranges
Index 1338