SIXTH EDITION - Pearson

3y ago
113 Views
37 Downloads
841.63 KB
18 Pages
Last View : 25d ago
Last Download : 3m ago
Upload by : Emanuel Batten
Transcription

Sebesta PWWW6e TTL-CR-DED.fm Page iii Tuesday, February 2, 2010 4:31 PMPR OGR AMM IN G T H EW ORLD W IDE W EBS I XTH EDI TI O NROBERT W. SEBESTAUniversity of Colorado at Colorado SpringsAddison-WesleyBoston Columbus Indianapolis New York San Francisco Upper Saddle RiverAmsterdam Cape Town Dubai London Madrid Milan Munich Paris Montreal TorontoDelhi Mexico City Sao Paulo Sydney Hong Kong Seoul Singapore Taipei Tokyo

Sebesta PWWW6e TTL-CR-DED.fm Page iv Tuesday, February 2, 2010 4:31 PMEditor in Chief: Michael HirschAcquisitions Editor: Matt GoldsteinEditorial Assistant: Chelsea BellManaging Editor: Jeffrey HolcombSenior Production Project Manager: Marilyn LloydMedia Producer: Katelyn BollerDirector of Marketing: Margaret WaplesMarketing Coordinator: Kathryn FerrantiSenior Manufacturing Buyer: Carol MelvilleText Designer: Gillian Hall/The Aardvark GroupCover Designer: Elena SidorovaCover Image: Andrew Parkinson/Getty ImagesProject Management: Dennis Free/Aptara , Inc.Full Service Vendor: Aptara, Inc.Text and Cover Printer: Courier StoughtonThe interior of this book was composed in FrameMaker 7.0, JansonText, Courier10PitchBTCopyright 2011, 2010, 2008, 2006, 2003, 2002 Pearson Education, Inc., publishing as Addison-Wesley. Allrights reserved. Manufactured in the United States of America. This publication is protected by Copyright, andpermission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrievalsystem, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, orlikewise. To obtain permission(s) to use material from this work, please submit a written request to PearsonEducation, Inc., Permissions Department, 501 Boylston Street, Suite 900, Boston, Massachusetts 02116.Many of the designations by manufacturers and seller to distinguish their products are claimed as trademarks.Where those designations appear in this book, and the publisher was aware of a trademark claim, thedesignations have been printed in initial caps or all caps.Library of Congress Cataloging-in-Publication DataSebesta, Robert W.Programming the World Wide Web, 2010 / Robert W. Sebesta. -- 6th ed.p. cm.Previous eds. under title: Programming the World Wide Web.ISBN 978-0-13-213081-31. Internet programming.2. World Wide Web. I. Sebesta, Robert W. Programming the World Wide Web. II. Title.QA76.625.S42 2010b006.7'6--dc2220090538551098765432 1—CRS—1413121110ISBN-10:0-13-213081-5ISBN-13: 978-0-13-213081-3

Sebesta PWWW6e TTL-CR-DED.fm Page v Tuesday, February 2, 2010 4:31 PMTo Aidan

Sebesta PWWW6e TTL-CR-DED.fm Page vi Tuesday, February 2, 2010 4:31 PM

Sebesta PWWW6e TOC.fm Page vii Tuesday, February 2, 2010 4:05 PMBrief Contents12345678910111213Fundamentals1Introduction to XHTML35Cascading Style Sheets91The Basics of JavaScript129JavaScript and XHTML DocumentsDynamic Documents with JavaScriptIntroduction to XMLIntroduction to FlashIntroduction to PHPIntroduction to AjaxJava Web Software185227265311353401431Introduction to ASP.NET495Database Access through the Web559vii

Sebesta PWWW6e TOC.fm Page viii Tuesday, February 2, 2010 4:05 PMviiiBrief Contents1415Introduction to Ruby601Introduction to Rails645Appendix A Introduction to Java 687Appendix B Named Colors 703Appendix C Java Applets 707Index 735

Sebesta PWWW6e TOC.fm Page ix Tuesday, February 2, 2010 4:05 .61.71.81.91A Brief Introduction to the Internet 2The World Wide Web 6Web Browsers 7Web Servers 8Uniform Resource Locators 11Multipurpose Internet Mail Extensions 13The Hypertext Transfer Protocol 15Security 18The Web Programmer’s Toolbox 20Summary 28Review Questions 30Exercises 322Introduction to XHTML2.12.22.32.42.52.62.72.82.92.1035Origins and Evolution of HTML and XHTML 36Basic Syntax 38Standard XHTML Document Structure 39Basic Text Markup 40Images 49Hypertext Links 54Lists 57Tables 63Forms 71Syntactic Differences between HTML and XHTML 84Summary 85Review Questions 86Exercises 88ix

Sebesta PWWW6e TOC.fm Page x Tuesday, February 2, 2010 4:05 PMxContents3Cascading Style 1Introduction 92Levels of Style Sheets 93Style Specification Formats 94Selector Forms 96Property Value Forms 99Font Properties 100List Properties 106Color 110Alignment of Text 112The Box Model 114Background Images 119The span and div Tags 121Conflict Resolution 122Summary 124Review Questions 126Exercises 1274The Basics of .134.14129Overview of JavaScript 130Object Orientation and JavaScript 133General Syntactic Characteristics 134Primitives, Operations, and Expressions 137Screen Output and Keyboard Input 146Control Statements 150Object Creation and Modification 158Arrays 159Functions 164An Example 169Constructors 170Pattern Matching Using Regular Expressions 171Another Example 176Errors in Scripts 177Summary 179Review Questions 181Exercises 183

Sebesta PWWW6e TOC.fm Page xi Tuesday, February 2, 2010 4:05 PMContents5JavaScript and XHTML Documents5.15.25.35.45.55.65.75.85.95.10185The JavaScript Execution Environment 186The Document Object Model 187Element Access in JavaScript 191Events and Event Handling 193Handling Events from Body Elements 197Handling Events from Button Elements 199Handling Events from Text Box and Password Elements 204The DOM 2 Event Model 214The navigator Object 219DOM Tree Traversal and Modification 221Summary 222Review Questions 223Exercises 2246Dynamic Documents with duction 228Positioning Elements 228Moving Elements 234Element Visibility 237Changing Colors and Fonts 238Dynamic Content 242Stacking Elements 245Locating the Mouse Cursor 249Reacting to a Mouse Click 251Slow Movement of Elements 253Dragging and Dropping Elements 256Summary 261Review Questions 262Exercises 2627Introduction to XML7.17.27.37.4265Introduction 266The Syntax of XML 268XML Document Structure 271Document Type Definitions 272227xi

Sebesta PWWW6e TOC.fm Page xii Tuesday, February 2, 2010 4:05 PMxiiContents7.57.67.77.87.97.107.11Namespaces 279XML Schemas 281Displaying Raw XML Documents 289Displaying XML Documents with CSS 291XSLT Style Sheets 293XML Processors 302Web Services 304Summary 305Review Questions 307Exercises 3098Introduction to Flash8.18.28.38.48.58.6311Origins and Uses of Flash 312A First Look at the Flash Authoring Environment 312Drawing Tools 318Static Graphics 327Animation and Sound 332User Interactions 343Summary 348Review Questions 350Exercises 3519Introduction to rigins and Uses of PHP 354Overview of PHP 354General Syntactic Characteristics 355Primitives, Operations, and Expressions 356Output 362Control Statements 364Arrays 367Functions 376Pattern Matching 379Form Handling 382Files 388Cookies 391Session Tracking 394Summary 394Review Questions 396Exercises 398

Sebesta PWWW6e TOC.fm Page xiii Tuesday, February 2, 2010 4:05 PMContents10Introduction to Ajax10.110.210.310.410.5401Overview of Ajax 402The Basics of Ajax 405Return Document Forms 415Ajax Toolkits 419Security and Ajax 427Summary 428Review Questions 429Exercises 43011Java Web ction to Servlets 432The NetBeans Integrated Development Environment 437A Survey Example 447Storing Information on Clients 454JavaServer Pages 463JavaBeans 475Model-View-Controller Application Architecture 479JavaServer Faces 480Summary 489Review Questions 490Exercises 49212Introduction to ASP.NET12.112.212.312.412.512.6495Overview of the .NET Framework 496A Bit of C# 499Introduction to ASP.NET 503ASP.NET Controls 510ASP.NET AJAX 540Web Services 546Summary 555Review Questions 556Exercises 55813Database Access through the Web13.113.213.313.4559Relational Databases 560An Introduction to the Structured Query Language 562Architectures for Database Access 567The MySQL Database System 569xiii

Sebesta PWWW6e TOC.fm Page xiv Tuesday, February 2, 2010 4:05 PMxivContents13.5 Database Access with PHP and MySQL 57213.6 Database Access with JDBC and MySQL 58113.7 Database Access with ASP.NET and MySQL 589Summary 596Review Questions 598Exercises 60014Introduction to igins and Uses of Ruby 602Scalar Types and Their Operations 602Simple Input and Output 610Control Statements 613Fundamentals of Arrays 618Hashes 623Methods 625Classes 630Blocks and Iterators 635Pattern Matching 638Summary 641Review Questions 642Exercises 64215Introduction to Rails15.115.215.315.4645Overview of Rails 646Document Requests 648Rails Applications with Databases 655Rails with Ajax 675Summary 683Review Questions 684Exercises 685Appendix A Introduction to Java 687Appendix B Named Colors 703Appendix C Java Applets 707Index 735

Sebesta PWWW6e PREF.fm Page xv Thursday, February 4, 2010 3:45 PMPrefaceIt is difficult to overestimate the effect the World Wide Web has had on theday-to-day lives of people, at least those in the developed countries. In just15 years, we have learned to use the Web for a myriad of disparate tasks, rangingfrom the mundane task of shopping for airline tickets to the crucial earlymorning gathering of business news for a high-stakes day trader.The speed at which millions of Web sites appeared in the last decade wouldseem to indicate that the technologies used to build them were sitting on theshelf, fully developed and ready to use, even before the Web was developed.Also, one might guess that the tens of thousands of people who built those siteswere sitting around unemployed, waiting for an opportunity and already possessing the knowledge and abilities required to carry out this mammoth construction task when it appeared. Neither of these was true. The need for newtechnologies was quickly filled by a large number of entrepreneurs, some atexisting companies and some who started new companies. A large part of theprogrammer need was filled, at least to the extent to which it was filled, by newprogrammers, some straight from high school. Many, however, were previouslyemployed by other sectors of the software development industry. All of themhad to learn to use new languages and technologies.A visit to a bookstore, either a bricks-and-mortar store or a Web site, willturn up a large supply of books on Web technologies aimed at the practicingprofessional. One difficulty encountered by those teaching courses in Web programming technologies in colleges is the lack of textbooks that are targeted totheir needs. Most of the books that discuss Web programming were written forprofessionals, rather than college students. Such books are written to fulfill theneeds of professionals, which are quite different from those of college students.One major difference between an academic book and a professional book lies inthe assumptions made by the author about the prior knowledge and experienceof the audience. On the one hand, the backgrounds of professionals vary widely,making it difficult to assume much of anything. On the other hand, a book written for junior computer science majors can make some definite assumptionsabout the background of the reader.xv

Sebesta PWWW6e PREF.fm Page xvi Thursday, February 4, 2010 3:45 PMxviPrefaceThis book is aimed at college students, not necessarily only computer science majors, but anyone who has taken at least two courses in programming.Although students are the primary target, the book is also useful for professionalprogrammers who wish to learn Web programming.The goal of the book is to provide the reader with a comprehensive introduction to the programming tools and skills required to build and maintainserver sites on the Web. A wide variety of technologies are used in the construction of a Web site. There are now many books available for professionals thatfocus on these technologies. For example, there are dozens of books that specifically address only XHTML. The same is true for a half-dozen other Web technologies. This book provides an overview of how the Web works, as well asdescriptions of many of the most widely used Web technologies.The first five editions of the book were used to teach a junior-level Webprogramming course at the University of Colorado at Colorado Springs. Thechallenge for students in the course is to learn to use several differentprogramming languages and technologies in one semester. A heavy load of programming exercises is essential to the success of the course. Students in thecourse build a basic, static Web site, using only XHTML as the first assignment.Throughout the remainder of the semester, they add features to their site as thenew technologies are discussed in the course. Our students’ prior course work inJava and data structures, as well as C and assembly language, is helpful, as is thefact that many of them have learned some XHTML on their own before takingthe course.The most important prerequisite to the material of this book is a solid background in programming in some language that supports object-oriented programming. It is helpful to have some knowledge of a second programminglanguage and a bit of UNIX, particularly if a UNIX-based Web server is usedfor the course. Familiarity with a second language makes learning the new languages easier.Table of ContentsThe book is organized into three parts: the introduction (Chapter 1), client-sidetechnologies (Chapters 2–8), and server-side technologies (Chapters 9–15).Chapter 1 lays the groundwork for the rest of the book. A few fundamentalsare introduced, including the history and nature of the Internet, the WorldWide Web, browsers, servers, URLs, MIME types, and HTTP. Also includedin Chapter 1 are brief overviews of the most important topics of the rest of thebook.Chapter 2 provides an introduction to XHTML, including images, links,lists, tables, and forms. Small examples are used to illustrate many of theXHTML elements that are discussed in this chapter.The topic of Chapter 3 is cascading style sheets, which provide the standardway of imposing style on the content specified in XHTML tags. Because of the

Sebesta PWWW6e PREF.fm Page xvii Thursday, February 4, 2010 3:45 PMPrefacexviisize and complexity of the topic, the chapter does not cover all of the aspects ofstyle sheets. The topics discussed are levels of style sheets, style specificationformats, selector formats, property values, and color. Among the properties covered are those for fonts, lists, and margins. Small examples are used to illustratethe subjects that are discussed.Chapter 4 introduces the core of JavaScript, a powerful language that couldbe used for a variety of different applications. Our interest, of course, is its usein Web programming. Although JavaScript has become a large and complexlanguage, we use the student’s knowledge of programming in other languages toleverage the discussion, thereby providing a useful introduction to the languagein a manageably small number of pages. Topics covered are the object model ofJavaScript, its control statements, objects, arrays, functions, constructors, andpattern matching.Chapter 5 discusses some of the features of JavaScript that are related toXHTML documents. Included is the use of the basic and DOM 2 event andevent-handling model, which can be used in conjunction with some of the elements of XHTML documents.One of the interesting applications of JavaScript is building dynamicXHTML documents with the Document Object Model (DOM). Chapter 6provides descriptions of a collection of some of the changes that can be made todocuments with the use of JavaScript and the DOM. Included are positioningelements; moving elements; changing the visibility of elements; changing thecolor, style, and size of text; changing the content of tags; changing the stacking order of overlapped elements; moving elements slowly; and dragging anddropping elements.Chapter 7 presents an introduction to XML, which provides the means todesign topic-specific markup languages that can be shared among users withcommon interests. Included are the syntax and document structure used byXML, data type definitions, namespaces, XML schemas, and the display ofXML documents with both cascading style sheets and XML transformations.Also included is an introduction to Web services and XML processors.Chapter 8 introduces the Flash authoring environment, which is used tocreate a wide variety of visual and audio presentations—in particular, those thatinclude animation. A series of examples is used to illustrate the developmentprocesses, including drawing figures, creating text, using color, creating motionand shape animations, adding sound tracks to presentations, and designing components that allow the user to control the Flash movie.Chapter 9 introduces PHP, a server-side scripting language that enjoys widepopularity, especially as a database access language for Web applications. Thebasics of the language are discussed, as well as the use of cookies and sessiontracking. The use of PHP as a Web database access language is covered inChapter 13.Chapter 10 introduces Ajax, the relatively recent technology that is used tobuild Web applications with extensive user interactions that are more efficientthan those same applications if they do not use Ajax. In addition to a thorough

Sebesta PWWW6e PREF.fm Page xviii Thursday, February 4, 2010 3:45 PMxviiiPrefaceintroduction to the concept and implementation of Ajax interactions, the chapterincludes discussions of return document forms, Ajax toolkits, and Ajax security.Several examples are used to illustrate approaches to using Ajax.Java Web software is discussed in Chapter 11. The chapter introduces themechanisms for building Java servlets and gives several examples of how servletscan be used to present interactive Web documents. The NetBeans framework isintroduced and used throughout the chapter. Support for cookies in servlets ispresented and illustrated with an example. Then JSP is introduced through aseries of examples, including the use of code-behind files. This discussion is followed by an examination of JavaBeans and JavaServer Faces, along with examplesto illustrate their use.Chapter 12 is an introduction to ASP.NET, although it begins with a briefintroduction to the .NET Framework and C#. ASP.NET Web controls andsome of the events they can raise and how those events can be handled areamong the topics discussed in this chapter. ASP.NET AJAX is also discussed.Finally, constructing Web services with ASP.NET is introduced. Visual Studiois introduced and used to develop all ASP.NET examples.Chapter 13 provides an introduction to database access through the Web.This chapter includes a brief discussion of the nature of relational databases,architectures for database access, the structured query language (SQL), and thefree database system MySQL. Then, three approaches to Web access to databases are discussed: using PHP, using Java JDBC, and using ASP.NET. All threeare illustrated with complete examples. All of the program examples in thechapter use MySQL.Chapter 14 introduces the Ruby programming language. Included are thescalar types and their operations, control statements, arrays, hashes, methods,classes, code blocks and iterators, and pattern matching. There is, of course,much more to Ruby, but the chapter includes sufficient material to allow thestudent to use Ruby for building simple programs and Rails applications.Chapter 15 introduces the Rails framework, designed to make the construction of Web applications relatively quick and easy. Covered are simple documentrequests, both static and dynamic; applications that use databases, including theuse of scaffolding; and Rails support for Ajax. Rails 2.0, which is not compatiblewith earlier versions of Rails, is used.Appendix A introduces Java to those who have experience with C andobject-oriented programming, but who do not know Java. Such students canlearn enough of the language fro

Programming the World Wide Web, 2010 / Robert W. Sebesta. -- 6th ed. p. cm. Previous eds. under title: Programming the World Wide Web. ISBN 978-0-13-213081-3 1. Internet programming. 2. World Wide Web. I. Sebesta, Robert W. Programming the World Wide Web. II. Title. QA76.625.S42 2010b 006.7'6--dc22 2009053855

Related Documents:

Pearson Education LTD. Pearson Education Australia PTY, Limited. Pearson Education Singapore, Pte. Ltd. Pearson Education North Asia, Ltd. Pearson Education Canada, Ltd. Pearson Educación de Mexico, S.A. de C.V. Pearson Education—Japan Pearson Education Malaysia, Pte. Ltd. The Libra

Pearson Education LTD. Pearson Education Australia PTY, Limited. Pearson Education Singapore, Pte. Ltd. Pearson Education North Asia, Ltd. Pearson Education Canada, Ltd. Pearson Educatión de Mexico, S.A. de C.V. Pearson Education—Japan Pearson Education Malaysia, Pte. Ltd. Library of Co

Pearson (UK) 80 Strand, London WC2R 0RL, UK T 44 (0)20 7010 2000 F 44 (0)20 7010 6060 firstname.lastname@pearson.com www.pearson.com Pearson (US) 1330 Avenue of the Americas, New York City, NY 10019, USA T 1 212 641 2400 F 1 212 641 2500 firstname.lastname@pearson-inc.com www.pearson.com Pearson Education One Lake Street, Upper Saddle River,

Fifth Edition 1977–1978 Sixth Edition 1979–1980 Seventh Edition 1981–1982 Eighth Edition 1983–1986 Ninth Edition 1987–1988 Tenth Edition 1989–1990 Eleventh Edition 1991–1992 Twelfth Edition 1993–1994 Thirteenth Edition 1995–1996 Fourteenth Edition 1997–1998 Fifteenth Edition

RP 2K, Second Edition RP 2L, Third Edition RP 2M, First Edition Bul 2N, First Edition RP 2P, Second Edition RP 2Q, Second Edition RP 2R, First Edition RP 2T, First Edition Bul 2U, First Edition Bul 2V, First Edition Spec 2W, First Edition RP 2X, First Edition, with Supp 1 Spec 2Y, First Edition

Pearson BTEC Level 4 HNC The Pearson BTEC Level 4 HNC in Business is a qualification with a minimum of 120 credits of which 60 are mandatory core. The Pearson BTEC Level 4 HNC programme must contain a minimum of 65 credits at level 4. Pearson BTEC Level 5 HND The Pearson BTEC Lev

Sixth Form Open Evening This evening is for parents and students who are considering an application to join the Sixth Form in September 2018. There is a general introduction to the Sixth Form by Dr Sievewright, senior staff and current sixth form students in the main school hall or gym at 6.45 p.m. After this you are welcome to tour the school.

Trinity has a dynamic, creative and successful Sixth Form. Housed in the Carliol Building, the Sixth Form Centre provides an ideal learning environment for young adults. The Sixth Form is a separate area and operates like a ‘college within a school.’ With around 300 students, Trinity Sixth Form is one of the largest