PROGRAMMING THE World Wide Web EIGHTH EDITION ROBERT W. SEBESTA University of Colorado at Colorado Springs PEARSON Boston Columbus Indianapolis New York San Francisco Upper Saddle River Amsterdam Cape Town Dubai London Madrid Milan Munich Paris Montreal Toronto Delhi Mexico City Sao Paulo Sydney Hong Kong Seoul Singapore Taipei Tokyo
^W^, n t@* ntft Fundamentals 1 1.1 A Brief Introduction to the Internet 2 1.2 The World Wide Web 6 1.3 Web Browsers 7 1.4 Web Servers 8 1.5 Uniform Resource Locators 11 1.6 Multipurpose Internet Mail Extensions 13 1.7 The Hypertext Transfer Protocol 15 1.8 Security 18 1.9 The Web Programmer's Toolbox 20 Summary 27 Review Questions 29 Exercises 31 Introduction to HTML/XHTML 33 2.1 Origins and Evolution of HTML and XHTML 34 2.2 Basic Syntax 38 2.3 Standard HTML Document Structure 39 2.4 Basic Text Markup 40 2.5 Images 49 2.6 Hypertext Links 55 2.7 Lists 58 2.8 Tables 63 2.9 Forms 69 2.10 The audio Element 83 2.11 The video Element 84 2.12 Organization Elements 86 2.13 The time Element 88 2.14 Syntactic Differences between HTML and XHTML 89 xiil
Summary 90 Review Questions 91 Exercises 93 Cascading Style Sheets 95 3.1 Introduction 96 3.2 Levels of Style Sheets 97 3.3 Style Specification Formats 98 3.4 Selector Forms 99 3.5 Property-Value Forms 103 3.6 Font Properties 105 3.7 List Properties 113 3.8 Alignment of Text 117 3.9 Color 119 3.10 The Box Model 121 3.11 Background Images 126 3.12 The <span> and <div> Tags 128 3.13 Conflict Resolution 129 Summary 132 Review Questions 133 Exercises 135 The Basics of JavaScript 137 4.1 Overview of JavaScript 138 4.2 Object Orientation and JavaScript 141 4.3 General Syntactic Characteristics 142 4.4 Primitives, Operations, and Expressions 145 4.5 Screen Output and Keyboard Input 154 4.6 Control Statements 158 4.7 Object Creation and Modification 165 4.8 Arrays 166 4.9 Functions 171 4.10 An Example 175 4.11 Constructors 177 4.12 Pattern Matching Using Regular Expressions 178 4.13 Another Example 182 4.14 Errors in Scripts 184 Summary 186 Review Questions 188 Exercises 190
Contents xv JavaScript and HTML Documents 193 5.1 The JavaScript Execution Environment 194 5.2 The Document Object Model 195 5.3 Element Access in JavaScript 199 5.4 Events and Event Handling 201 5.5 Handling Events from Body Elements 205 5.6 Handling Events from Button Elements 207 5.7 Handling Events from Text Box and Password Elements 212 5.8 The DOM 2 Event Model 222 5.9 The canvas Element 228 5.10 The navigator Object 232 5.11 DOM Tree Traversal and Modification 234 Summary 235 Review Questions 236 Exercises 237 Dynamic Documents with JavaScript 239 6.1 Introduction 240 6.2 Positioning Elements 240 6.3 Moving Elements 246 6.4 Element Visibility 249 6.5 Changing Colors and Fonts 250 6.6 Dynamic Content 254 6.7 Stacking Elements 257 6.8 Locating the Mouse Cursor 261 6.9 Reacting to a Mouse Click 263 6.10 Slow Movement of Elements 265 6.11 Dragging and Dropping Elements 268 Summary 273 Rew'ew Questions 273 Exercises 274 Introduction to XML 277 7.1 Introduction 278 7.2 Uses of XML 280 7.3 The Syntax of XML 281 7.4 XML Document Structure 283 7.5 Namespaces 285
xvi Contents 7.6 XMLSchemas 286 7.7 Displaying Raw XML Documents 294 7.8 Displaying XML Documents with CSS 296 7.9 XSLT Style Sheets 298 7.10 XML Processors 307 7.11 Web Services 309 Summary 311 Review Questions 312 Exercises 313 8 Introduction to Flash 315 8.1 Origins and Uses of Rash 316 8.2 A First Look at the Rash Authoring Environment 316 8.3 Drawing Tools 322 8.4 Static Graphics 331 8.5 Animation and Sound 336 8.6 User Interactions 347 Summary 352 Review Questions 353 Exercises 355 9 Introduction to PHP 357 9.1 Origins and Uses of PHP 358 9.2 Overview of PHP 358 9.3 General Syntactic Characteristics 359 9.4 Primitives, Operations, and Expressions 360 9.5 Output 365 9.6 Control Statements 367 9.7 Arrays 371 9.8 Functions 379 9.9 Pattern Matching 383 9.10 Form Handling 386 9.11 Cookies 392 9.12 Session Tracking 394 Summary 395 Review Questions 396 Exercises 398
Contents xvii Introduction to Ajax 401 10.1 Overview of Ajax 402 10.2 The Basics of Ajax 405 10.3 Return Document Forms 415 10.4 Ajax Toolkits 419 10.5 Security and Ajax 427 Summary 428 Review Questions 428 Exercises 429 Web Software 431 Introduction to Servlets 432 The NetBeans Integrated Development Environment 437 A Survey Example 445 Storing Information on Clients 453 JavaServer Pages 462 JavaBeans 474 Model-View-Controller Application Architecture 479 JavaServer Faces 480 Summary 488 Review Questions 489 Exercises 491 Introduction to ASP.NET 493 12.1 Overview of the.net Framework 494 12.2 A Bit of C# 497 12.3 Introduction to ASPNET 502 12.4 ASP.NET Controls 508 12.5 ASP.NET AJAX 539 12.6 Web Services 544 Summary 553 Review Questions 555 Exercises 556
Database Access through the Web 559 13.1 Relational Databases 560 13.2 An Introduction to the Structured Query Language 562 13.3 Architectures for Database Access 567 13.4 The MySQL Database System 569 13.5 Database Access with PHP and MySQL 572 13.6 Database Access with JDBC and MySQL 581 13.7 Database Access with ASP.NET and MySQL 588 Summary 595 Review Questions 596 Exercises 598 14 Android Software Development 599 14.1 Overview 600 14.2 The Tools 602 14.3 The Architecture of Android Applications 602 14.4 The Execution Model for Android Applications 603 14.5 View Groups 605 14.6 Simple Views 606 14.7 An Example Application 609 14.8 Running an Application on an Android Device 618 14.9 Using the intent Class to Call Other Activities 619 14.10 An Example Application: A Second Activity 620 14.11 More Widgets 628 14.12 Dealing with Lists 632 14.13 Data Persistence 637 14.14 Debugging Applications 641 Summary 643 Review Questions 644 Exercises 645
Contents xlx Introduction to Ruby 647 15.1 Origins and Uses of Ruby 648 15.2 Scalar Types and Their Operations 648 15.3 Simple Input and Output 656 15.4 Control Statements 659 15.5 Fundamentals of Arrays 664 15.6 Hashes 669 15.7 Methods 671 15.8 Classes 676 15.9 Blocks and Iterators 681 15.10 Pattern Matching 684 Summary 687 Review Questions 687 Exercises 688 Introduction to Rails 691 16.1 Overview of Rails 692 16.2 Document Requests 694 16.3 Rails Applications with Databases 700 Summary 718 Rew'ew Questions 719 Exercises 720 Appendix A Introduction to Java 721 A.l Overview of Java 722 A.2 Data Types and Structures 724 A.3 Classes, Objects, and Methods 726 A.4 Interfaces 730 A.5 Exception Handling 730 Summary 735 Appendix B Named Colors and Their Hexadecimal Values 737 Index 741