Core Web Programming / Edition 2

Core Web Programming / Edition 2

ISBN-10:
0130897930
ISBN-13:
9780130897930
Pub. Date:
06/07/2001
Publisher:
Prentice Hall
ISBN-10:
0130897930
ISBN-13:
9780130897930
Pub. Date:
06/07/2001
Publisher:
Prentice Hall
Core Web Programming / Edition 2

Core Web Programming / Edition 2

$59.99 Current price is , Original price is $59.99. You
$59.99 
  • SHIP THIS ITEM
    This item is available online through Marketplace sellers.
  • PICK UP IN STORE
    Check Availability at Nearby Stores
$21.02 
  • SHIP THIS ITEM

    Temporarily Out of Stock Online

    Please check back later for updated availability.

    • Condition: Good
    Note: Access code and/or supplemental material are not guaranteed to be included with used textbook.

This item is available online through Marketplace sellers.


Overview

One-stop shopping for serious Web developers!

  • The worldwide best seller for serious Web developers—now 100% updated!
  • In-depth HTML 4/CSS, Java 2, Servlets, JSP, XML, and more!
  • Industrial-strength code examples throughout!

The authoritative guide to every technology that enterprise Web developers need to master, from HTML 4 to Java 2 Standard Edition 1.3, servlets to JavaServer Pages, and beyond. Core Web Programming, Second Edition brings them all together in the ultimate Web development resource for experienced programmers.

HTML 4: In-depth, practical coverage of HTML document structure, block-level and text-level elements, frames, cascading style sheets, and beyond.

Java 2: Basic syntax, object-oriented design, applets and animation, the Java Plug-In, user interface development with Swing, layout managers, Java2D, multithreading, network programming, database connectivity, and more.

Server-Side Java: Servlets, JSP, XML, and JDBC-the foundations of enterprisedevelopment with Java. Advanced topics include JSP custom tag libraries,combining servlets and JSP (MVC), database connection pooling, SAX, DOM, and XSLT processing, and detailed coverage of HTTP 1.1.

JavaScript: Dynamic creation of Web page content, user event monitoring, HTML form field validation, and more. Includes a complete quick reference guide.

This book's first edition is used in leading computer science programs worldwide, from MIT to Stanford, UC Berkeley to Princeton, UCLA to Johns Hopkins. Now, it's been 100% updated for today's hottest Web development technologies—with powerful new techniques, each with complete working code examples!

Every Core Series book:

  • DEMONSTRATES practical techniques used by professional developers
  • FEATURES robust, thoroughly tested sample code and realistic examples
  • FOCUSES on the cutting-edge technologies you need to master today
  • PROVIDES expert advice that will help you build superior software

Core Web Programming delivers:

  • Practical insights for Web development with HTML, CSS, and JavaScript
  • Expert J2SE 1.3 coverage, from Swing and Java 2D to threading, RMI, and JDBC
  • Fast-track techniques for server-side development with servlets, JSP, and XML
  • Hundreds of real-world code examples, including complete sample applications

Product Details

ISBN-13: 9780130897930
Publisher: Prentice Hall
Publication date: 06/07/2001
Series: Core Series
Edition description: Two Volume Set
Pages: 1440
Product dimensions: 7.08(w) x 8.97(h) x 2.83(d)

About the Author

MARTY HALL is the author of Core Servlets and JavaServer Pages, the world's most popular book on servlet and JSP technology. He is a Senior Computer Scientist at the Johns Hopkins University Applied Physics Laboratory.

LARRY BROWN is a Senior Network Engineer at the Naval Sea Systems Command, Carderock Division. He is also a Computer Science faculty member at the Johns Hopkins University, where he teaches server-side programming, distributed Web programming, and Java user interface development for the part-time graduate program in Computer Science.

Read an Excerpt

Chapter 23: XML Processing with Java

ML is a "meta" markup language used to describe the structure of data. XML has taken the computer industry by storm since its inception and is now the markup language of choice for configuration files, data interchange, B2B transactions, and Java 2 Enterprise architectures. XML is even being used to represent calls to distributed objects through the Simple Object Access Protocol (SOAP), an XML application.

XML has numerous advantages including being easy to read, easy to parse, extensible, and widely adopted. In addition, you can define a grammar through a Document Type Definition (DTD) to enforce application-specific syntax. However, the greatest single advantage of XML is that the data can be easily processed by other applications; XML data is not in a proprietary format. In essence, XML has done for data what the Java language has done for programs:

Java = Portable Programs
XML = Portable Data

This chapter doesn't focus on how to write XML but rather how to process XML documents with Java. We show you how to use Java to process XML documents by using the Document Object Model (DOM), the Simple API for XML (SAX), and the Extensible Style sheet Language for Transformations (XSLT). If you are new to XML, here are some good starting points for additional information:

XML 1.0 Specification
http://www.w3.org/TR/REC-xml

Sun Page on XML and Java
http://java.sun.com/xml/

WWW Consortium's Home Page on XML
http://www.w3.org/XML/

Apache XML Project
http://xml.apache.org/

XML Resource Collection
http://xml.coverpages.org/

O'Reilly XML Resource Center
http://www.xml.com/

23.1 Parsing XML Documents with DOM Level 2

The Document Object Model (DOM) represents an entire XML document in a tree-like data structure that can be easily manipulated by a Java program. The advantages of DOM are that it is relatively simple to use and you can modify the data structure in addition to extracting data from it. However, the disadvantage is that DOM parses and stores the entire document, even if you only care about part of it. Section 23.3 (Parsing XML Documents with SAX 2.0) discusses an alternative approach appropriate for cases when you are dealing with very large XML documents but care about only small sections of them.

Installation and Setup

DOM is not a standard part of either Java 2 Standard Edition or the servlet and JSP APIs. So, your first step is to download the appropriate classes and configure them for use in your programs. Here is a summary of what is required.
  1. Download a DOM-compliant parser. The parser provides the Java classes that follow the DOM Level 2 API as specified by the WWW Consortium. You can obtain a list of XML parsers in Java at http://www.xml.com/pub/rg/Java_Parsers. We use the Apache Xerces-J parser in this book. See http://xml.apache.org/xerces-j/. This parser also comes with the complete DOM API in Javadoc format.

  2. Download the Java API for XML Processing (JAXP). This API provides a small layer on top of DOM that lets you plug in different vendor's parsers without making any changes to your basic code. See http://java.sun.com/xml/.

  3. Set your CLASSPATH to include the DOM classes. In the case of Apache Xerces, you need to include xerces_install_dir\ xerces.jar. For example, for desktop applications on Windows you would do set CLASSPATH=xerces_install_dir\xerces.jar;%CLASSPATH% If you wanted to use DOM from servlets and JSP, you would copy the appropriate JAR file to the server's lib directory (if supported), unpack the JAR file (using jar -xvf) into the server's classes directory, or explicitly change the server's CLASSPATH, usually by modifying the server start-up script.

  4. Set your CLASSPATH to include the JAXP classes. These classes are in jaxp_install_dir/jaxp.jar. For example, on Unix/Linux and the C shell, you would do setenv CLASSPATH jaxp_install_dir/jaxp.jar:$CLASSPATH For use from servlets and JSP, see the preceding step.

  5. Bookmark the DOM Level 2 and JAXP APIs. The official DOM specification can be found at http://www.w3.org/TR/ DOM-Level-2-Core/, but the API in Javadoc format that comes with Apache Xerces is easier to read and also includes the JAXP and SAX (see Section 23.3) APIs.

  6. Print the JAXP specification for your reference. Download it from http://java.sun.com/xml/jaxp-1_1-spec.pdf.

Parsing

With DOM processing, there are two high-level tasks: turning an XML document into a DOM data structure and looking through that data structure for the data that interests you. The following list summarizes the detailed steps needed to accomplish these tasks....

Table of Contents

Introduction.

Acknowledgments.

I. THE HYPERTEXT MARKUP LANGUAGE.

1. Designing Web Pages with HTML 4.0.

2. Block-Level Elements in HTML 4.0.

3. Text-Level Elements in HTML 4.0.

4. Frames.

5. Cascading Style Sheets.

II. JAVA PROGRAMMING.

6. Getting Started with Java.

7. Object-Oriented Programming in Java.

8. Basic Java Syntax.

9. Applets and Basic Graphics.

10. Java 2D: Graphics in Java 2.

11. Handling Mouse and Keyboard Events.

12. Layout Managers.

13. AWT Components.

14. Basic Swing.

15. Advanced Swing.

16. Concurrent Programming with Java Threads.

17. Network Programming.

III. SERVER-SIDE PROGRAMMING.

18. HTML Forms.

19. Server-Side Java Servlets.

20. Javaserver Pages.

21. Using Applets as Front Ends to Server-Side Programs.

22. JDBC.

23. XML Processing with Java.

IV. JAVASCRIPT.

24. JavaScript: Adding Dynamic Content to Web Pages.

25. JavaScript Quick Reference.

Index.

Preface

Introduction

In late 1995, Marty Hall proposed a new course for the part-time graduate program in Computer Science at the Johns Hopkins University. The idea was to bring together the major Web-related topics in a single course dubbed "Distributed Development on the World Wide Web," with Java technology as a unifying theme. Students would look at HTML, Java, HTTP, CGI programming, and JavaScript, with lots of hands-on projects and no exams. Little did Marty know what he was getting himself into. By the time the first section was offered in the summer of 1996, the Java tidal wave had swept through the university and the companies that the students represented. Shortly after enrollment opened, the class was filled. There were more students on the waiting list than in the course. Marty got frantic phone calls from students insisting that they absolutely had to be in the course. Several local companies called, asking for on-site courses. What fun!

However, when Marty went shopping for texts over the next semester or two, he got a rude surprise. Despite the availability of good books in most of the individual areas he wanted to cover, Marty found that he needed three, four, or even five separate books to get good coverage of the overall material. Similarly, for his day job, Marty was constantly switching back and forth among the best of the huge stack of books he had accumulated and various on-line references. Surely there was a better way. Shouldn't it be possible to fit 85 percent of what professional programmers use in about 35 percent of the space, and get it all in one book?

That was the genesis of the first edition of Core Web Programming. The book was very popular, but the industry has been rapidly moving since the book's release. Browsers moved from HTML 3.2 to 4.0. The Java 2 platform was released, providing greatly improved performance and graphics libraries suitable for commercial-quality applications. JSP 1.0 came along, resulting in an explosion of interest in both servlets and JSP as an alternative to CGI and to proprietary solutions like ASP and ColdFusion. XML burst upon the scene. The server equalled or even surpassed the desktop as the biggest application area for the Java programming language.

Wow. And demand has only been growing since then. Although readers were clamoring for a new edition of the book, it was just too much for Marty to handle alone. Enter Larry Brown, with broad development and teaching experience in Java and Web technologies, and with particular expertise in the Java Foundation Classes, multithreaded programming, RMI, and XML processing with Java. Larry teamed up with Marty to totally update the existing material to HTML 4, CSS/1, HTTP 1.1, and the Java 2 platform; to replace the CGI sections with chapters on servlets 2.2 and JSP 1.1; and to add completely new sections on Swing, Java 2D, and XML processing with JAXP, DOM Level 2, SAX 2.0, and XSLT. They even got a little bit of sleep along the way.

We—Marty and Larry—hope you find the result enjoyable and useful!

Real Code for Real Programmers

This book is aimed at serious software developers. If you are looking for a book that shows you how to use a browser, lists the current hottest Web sites, and pontificates about how Web-enabled applications will revolutionize your business, you've come to the wrong place. If you're already a programmer of some sort and want to get started with HTML, XML, Java applets, desktop applications in Java, servlets, JavaServer Pages, and JavaScript as quickly as possible, this is the book for you. We illustrate the most important approaches and warn you of the most common pitfalls. To do so, we include plenty of working code: over 250 complete Java classes, for instance. We try to give detailed examples of the most important and frequently used features, summarize the lesser-used ones, and refer you to the API (available on-line) for a few of the rarely used ones.

A word of caution, however. Nobody becomes a great developer just by reading. You have to write some real code too. The more, the better. In each chapter, we suggest that you start by making a simple program or a small variation of one of the examples given, then strike off on your own with a more significant project. Skim the sections you don't plan on using right away, then come back when you are ready to try them out.

If you do this, you should quickly develop the confidence to handle the real-world problems that brought you here in the first place. You should be able to balance the demand for the latest features in Web pages with the need for multiplatform support. You should be comfortable with frames, style sheets, and layered HTML. You should be able to make portable stand-alone graphical applications. You should have no qualms about developing Web interfaces to your corporate database through JDBC. You should be able to connect these applications to remote systems over the network. You should understand how to easily distribute computation among multiple threads, or even spin it off to separate systems by using RMI. You should be able to decide where servlets apply well, where JSP is better, and where a combination is best. You should understand HTTP 1.1 well enough to use its capabilities to enhance the effectiveness of your pages. You should be able to spin off complex server-side behaviors into JavaBeans components or custom JSP tag libraries. You should be able to use JavaScript to validate HTML forms or to animate Web pages. You should get a raise. A big one, preferably.

How This Book Is Organized

This book is divided into four parts: HTML, Java programming, server-side programming, and JavaScript.

Part 1: The HyperText Markup Language

Web pages are created with HTML, the HyperText Markup Language. HTML lets you mix regular text with special tags that describe the content, layout, or appearance of the text. These tags are then used by Web browsers like Netscape Navigator or Microsoft Internet Explorer to format the page. This first part of the book covers the following topics in HTML.

  • HTML 4.01. Full coverage of all the elements in the latest official HTML standard. Hypertext links, fonts, images, tables, client-side image maps, and more.
  • Major Netscape and Internet Explorer extensions. Forwarding pages, using custom colors and font faces, embedding audio, video, and ActiveX components.
  • Frames. Dividing the screen into rectangular regions, each associated with a separate HTML document. Borderless frames. Floating frames. Targeting frame cells from hypertext links.
  • Cascading style sheets. Level-one style sheets for customizing fonts, colors, images, text formatting, indentation, lists, and more.

Part 2: Java Programming

Java is a powerful general-purpose programming language that can be used to create stand-alone programs as well as ones that are embedded in Web pages. The following Java topics are covered.

  • Unique features of Java. What's different about Java? The truth about Java myths and hype.
  • Object-oriented programming in Java. Variables, methods, constructors, overloading, and interfaces. Modifiers in class declarations. Packages, the CLASSPATH, and JAR files.
  • Java syntax. Primitive types, operators, strings, vectors, arrays, input/output and the Math class.
  • Graphics. Applets. Applications. Drawing, color, font, and clipping area operations. Loading and drawing images. Java Plug-In.
  • Java 2D. Creating professional, high-quality 2D graphics. Creating custom shapes, tiling images, using local fonts, creating transparent shapes, and transforming coordinates.
  • Mouse and keyboard events. Processing events. Event types, event listeners, and low-level event handlers. Inner classes. Anonymous classes.
  • Layout managers. FlowLayout, BorderLayout, GridLayout, CardLayout, GridBagLayout, and BoxLayout. Positioning components by hand. Strategies for using layout managers effectively.
  • AWT components. Canvas, Panel, Applet, ScrollPane, Frame, Dialog, FileDialog, and Window.Component and Container. Buttons, check boxes, radio buttons, combo boxes, list boxes, textfields, text areas, labels, scrollbars, and pop-up menus. Saving and loading windows with object serialization.
  • Basic Swing components. Building Swing applets and applications. Changing the GUI look and feel. Adding custom borders to components. Using HTML in labels and buttons. Sending dialog alerts for user input. Adding child frames to applications. Building custom toolbars. Implementing a Web browser in Swing.
  • Advanced Swing. JList, JTree, and JTable. Using custom data models and renderers. Printing Swing components. Updating Swing components in a thread-safe manner.
  • Multithreaded programming. Threads in separate or existing objects. Synchronizing access to shared resources. Grouping threads. Multithreaded graphics and double buffering. Animating images. Controlling timers.
  • Network programming. Clients and servers using sockets. The URL class. Implementing a generic network server. Creating a simple HTTP server. Invoking distributed objects with RMI.

Part 3: Server-Side Programming

Programs that run on a Web server can generate dynamic content based on client data. Servlets are Java technology's answer to CGI programming and JSP is Java's answer to Active Server Pages or ColdFusion. The following server-side topics are discussed.

  • HTML forms. Sending data from forms. Text controls. Push buttons. Check boxes and radio buttons. Combo boxes and list boxes. File upload controls. Server-side image maps. Hidden fields. Tab ordering.
  • Java servlets. The advantages of servlets over competing technologies. Servlet life cycle. Servlet initialization parameters. Accessing form data. Using HTTP 1.1 request headers, response headers, and status codes. Using cookies in servlets. Session tracking.
  • JavaServer Pages (JSP). The benefits of JSP. JSP expressions, scriptlets, and declarations. Using JavaBeans components with JSP. Creating custom JSP tag libraries. Combining servlets and JSP.
  • Using applets as servlet front ends. Sending GET and POST data. HTTP tunneling. Using object serialization to exchange high-level data structures between applets and servlets. Bypassing the HTTP server altogether.
  • Java Database Connectivity (JDBC). The seven basic steps in connecting to databases. Some utilities that simplify JDBC usage. Formatting a database result as plain text or HTML. An interactive graphical query viewer. Precompiled queries.
  • XML processing with Java. Representing an entire XML document by using the Document Object Model (DOM) Level 2. Responding to individual XML parsing events with the Simple API for XML Parsing (SAX) 2.0. Transforming XML with XSLT. Hiding vendor-specific details with the Java API for XML Processing (JAXP).

Part 4: JavaScript

JavaScript is a scripting language that can be embedded in Web pages and interpreted as the pages are loaded. The final part covers the following JavaScript topics.

  • JavaScript syntax. Fields, methods, functions, strings, objects, arrays, and regular expressions.
  • Customizing Web pages. Adapting to different browsers, JavaScript releases, and screen sizes.
  • Making pages dynamic. Animating images. Manipulating layers. Responding to user events.
  • Validating HTML forms. Checking form entries as they are changed. Checking data when form is submitted.
  • Handling cookies. Reading and setting values. The Cookie object.
  • Controlling frames. Sending results to specific frames. Preventing documents from being framed. Updating multiple frame cells. Giving frame cells the focus automatically.
  • Integrating Java and JavaScript. LiveConnect and the JSObject class.
  • JavaScript quick reference. Major classes in JavaScript 1.2. All fields, methods, and event handlers. Document, Window, Form, Element, String, Math, RegExp, and so forth.

About the Web Site

The book has a companion Web site at

http://www.corewebprogramming.com/ 

This free site includes:

  • Documented source code for all examples shown in the book; this code can be downloaded for unrestricted use.
  • On-line versions of all HTML pages, Java applets, and JavaScript examples.
  • Links to all URLs mentioned in the text of the book.
  • Information on book discounts.
  • Reports on Java short courses.
  • Book additions, updates, and news.
  • A free Ronco combination paring knife and e-commerce tool. OK, maybe not.

About the Authors

Marty Hall is a Senior Computer Scientist in the Research and Technology Development Center at the Johns Hopkins University Applied Physics Lab, where he specializes in the application of Java and Web technology to customer problems. He also teaches Java and Web programming in the Johns Hopkins part-time graduate program in Computer Science, where he directs the Distributed Computing and Web Technology concentration areas. When he gets a chance, he also teaches industry short courses on servlets, JavaServer Pages, and other Java technology areas. He is the author of Core Servlets and JavaServer Pages and the first edition of Core Web Programming. Marty can be reached at the following address:

Research and Technology Development Center
The Johns Hopkins University Applied Physics Laboratory
11100 Johns Hopkins Road
Laurel, MD 20723
hall@corewebprogramming.com

Larry Brown is a Senior Network Engineer at the Naval Surface Warfare Center, Carderock Division, where he specializes in developing and deploying network and Web solutions in an enterprise environment. He is also a Computer Science faculty member at the Johns Hopkins University, where he teaches server-side programming, distributed Web programming, and Java user interface development for the part-time graduate program in Computer Science. Larry can be reached at the following address:

Naval Surface Warfare Center, Carderock Division
9500 MacArthur Boulevard
West Bethesda, MD 20817
brown@corewebprogramming.com
From the B&N Reads Blog

Customer Reviews