站内搜索: 请输入搜索关键词
当前页面: 图书首页 > XML and Java: Developing Web Applications, Second Edition

XML and Java: Developing Web Applications, Second Edition

[ directory ] Previous Section Next Section

1.1 Introduction

This book is about how to design and develop Web applications based on Extensible Markup Language (XML), Java, and emerging technologies around XML and Java. The term "Web application" may be a little too restrictive here梩he techniques described can be applied to any server-side system that manipulates content in XML. In particular, we focus heavily on business-to-business (B2B) applications梙ow such applications can send, receive, verify, and manipulate XML documents that are exchanged among companies. In addition to XML and Java, a number of emerging technologies will facilitate the design and implementation of B2B applications, such as Web application server, Simple Object Access Protocol (SOAP), Web services, and data binding. This book also explains the benefits and potential pitfalls of these new technologies.

This book is not intended to be an introduction to XML or Java. A number of books are available for those who need a quick understanding of XML or Java. We assume that readers have a basic understanding of XML and experience in writing simple Java programs. If you have already built one or more Web applications or you have a background in designing and building business applications, that will help you understand the material presented in this book. We recommend that you have both the XML and Java references that are listed in Appendix B handy when we walk you through the sample applications.

One of the wonderful things about Internet technologies is that many useful resources, such as tools, language processors, documents, and sample programs, can be downloaded from the Internet for free. Appendix B also contains a list of links that we are sure you will find useful. The following are two URLs that you must know. You should consult these links whenever you need in-depth information or to obtain the latest information on XML and Java. (Because the Internet is changing rapidly, there are many things that we could not include in this book simply because they were not available at the time of writing. It is the reader's responsibility to check whether the information in this book is current and compliant with the latest standards.)

  • http://www.w3.org/?/b> This is the official site of the World Wide Web Consortium (W3C). All the official documents on XML should be available from this site.

  • http://java.sun.com/?/b> This is the home of Java. The latest Java 2 Software Development Kit (SDK) is downloadable from this site.

We use a number of sample programs in this book in order to strengthen our discussion. Readers are encouraged to run these programs and understand how they work. Each program was designed and coded by one or more of the authors and tested with Java 2 SDK versions 1.2.2 and 1.3.1 running on Windows 2000/XP and Linux. They should also run on any other platform with an appropriate Java Runtime Environment (JRE). These programs are provided on the accompanying CD-ROM along with the source code. The CD-ROM also contains the latest versions of middleware that are required to run the sample programs. They include Xerces as an XML processor, Tomcat as a Java servlet engine, and DB2 as a database. The CD-ROM has one directory for each chapter, and each directory has a Readme file. Please refer to the detailed instructions on how to run the sample code on your platform.

1.1.1 Structure of This Book

This book is divided into two parts. Part 1, Chapter 1 through Chapter 9, covers the basic technologies, while Part 2, Chapter 10 through Chapter 16, deals with emerging technologies and more advanced topics.

The goal of Part 1 is to teach you the programming techniques that you absolutely need to know when dealing with XML梙ow you can parse, generate, and transform XML documents and how you can use the standard Application Program Interfaces (APIs) and tools during these processes. If you are asked to develop a Java application that reads and writes XML, you should be ready to take on the job using the knowledge acquired while reading Part 1.

Part 1 consists of the following chapters (the author who wrote the chapter is shown in parentheses).

Chapter 1, Web Applications, XML, and Java (Maruyama). The rest of this chapter reviews the history and the future of Web applications, describing the roles of XML and Java, and introduces some important concepts about the use of XML.

Chapter 2, Parsing XML Documents (Uramoto). This chapter introduces the most basic operation of XML processing, parsing, which analyzes XML documents and makes the contents available to application programs through a set of APIs.

Chapter 3, Generating and Serializing XML Documents (Uramoto). The reverse operation of parsing is generating XML documents. This chapter discusses how to generate XML documents from the application's internal structure.

Chapter 4, Working with DOM (Tamura). The Document Object Model (DOM) is a tree-based standard API for accessing the internal structure of XML documents. This chapter introduces the DOM Level 1 and DOM Level 2 APIs and gives advice on how to use these APIs in various situations.

Chapter 5, Working with SAX (Tamura). Simple API for XML (SAX) is another standard API for XML. Unlike DOM, it is based on an event model rather than the tree model. This chapter explains the use of SAX and compares it with the DOM API.

Chapter 6, Parser Tricks (Clark). XML processors are complex software having many features that can be used in many different scenarios. This chapter shows the most commonly used techniques for making the most use of existing XML processors.

Chapter 7, XPath and XSLT (Neyama). The DOM and SAX APIs are powerful and flexible enough to allow any complex operations on XML documents. However, simple tasks, such as extracting certain attribute values or renaming element names, can be done in a simpler way with the use of XPath and Extensible Stylesheet Language Transformations (XSLT). This chapter explains the capability of XPath and XSLT for DOM and SAX and discusses the use of XPath and XSLT in Java applications.

Chapter 8, Bridging Application Data Structure and XML (Maruyama). After an XML document is parsed, it is often necessary to convert the parsed result into an application-specific data structure. Chapter 8 addresses this topic by showing program examples of mapping XML into tree, table, and graph structures.

Chapter 9, Working with Schemas: Datatypes and Namespaces (Murata). The Document Type Definition (DTD) has been used to describe a permissible syntax for a set of XML documents for a particular application. However, there are a few drawbacks to the DTD, and attempts are underway to define new schema languages. In Chapter 9, we explain two concrete examples of such efforts, W3C XML Schema and OASIS RELAX NG, focusing on the two practically important aspects: datatypes and namespace handling.

Part 2, consisting of Chapters 10 through 16, is organized around the major middleware technologies that enable XML- and Java-based Web application development. Unlike the basic XML tools, such as XML processors and XSLT processors, discussed in Part 1, these middleware technologies do not directly deal with XML but assist in the deployment of XML technologies in many different aspects of B2B systems, such as communicating using XML, storing and retrieving XML to and from databases, and securing B2B systems. The relationships between some of these technologies are depicted in Figure 1.1.

Figure 1.1. Chapters in Part 2

graphics/01fig01.gif

Chapter 10, XML Application Server (Neyama). The first middleware is the server platform for Java applications桽ervlet. This chapter explains the basics of Servlet and the use of Servlet and JavaServer Pages (JSP) for XML applications.

Chapter 11, XML and Databases (Uramoto). Most Web applications are connected to some sort of backend database. XML data can be stored into or originated from such a database. This chapter describes APIs and techniques for interfacing XML-based applications with backend databases. It also touches on the use of Enterprise JavaBeans (EJB) for database transactions.

Chapter 12, XML Messaging (Nakamura). The most important use of XML is as the standard messaging format between applications. Simple Object Access Protocol (SOAP) is becoming the foundation of Internet-based B2B communications. This chapter explores the basis of these protocols and shows how they can be used to integrate multiple systems in a decentralized manner.

Chapter 13, Web Services (Nakamura). XML, HTTP, and SOAP are giving rise to a new concept of Web services, where software functions are provided by Web applications through HTTP/XML-based protocols rather than traditional class libraries and software components. This chapter introduces the emerging technologies that enable the idea of Web services梚ncluding the Web Services Description Language (WSDL) and Universal Description, Discovery, and Integration (UDDI)梐nd discusses the application development processes within this new programming model.

Chapter 14, Security (Maruyama). When we conduct B2B communications on the Internet, one of our biggest concerns is security. This chapter covers the standard techniques for securing B2B applications and discusses design considerations.

In Chapters 15 and 16 we go back to XML itself, but on advanced topics that have recently gained attention.

Chapter 15, Data Binding (Maruyama). Although DOM and SAX provide generic APIs that can be used for any purpose, they do not reflect the application-specific data structure. The idea of data binding is to use XML Schema (or its equivalent) for bridging XML parsing with the application-specific data structure automatically. This chapter discusses the potential of this new technology.

Chapter 16, Principles of Schema Languages (Murata). Several ways of describing XML grammar are being proposed. They include RELAX, which was developed by one of the authors (Murata). These alternatives have their own distinctive features that would make building XML applications much easier in certain ways. Discussions in this chapter shed light on the possibilities of these new ideas.

It is not our intention to give you detailed information on each technology. Instead, the goal of Part 2 is to give you enough information so that you can make intelligent decisions about what technology you should pick in a given situation. We believe that a good system designer is one who always makes the right decisions about what middleware and technology should be used, by taking the customer's requirements and the environmental constraints into account. We hope the chapters in Part 2 help you to be a good system designer.

We provide some useful information in the appendixes.

Appendix A, About the CD-ROM. The contents of the associated CD-ROM and instructions for using it are described here.

Appendix B, Useful Links and Books. This is a useful but incomplete compilation of links on the Internet.

Appendix C, XML-Related Standardization Activities. A number of standards are being defined on top of XML. Appendix C covers the important ones.

Appendix D, JDBC Primer. The standard API for accessing relational databases from a Java program is Java Database Connectivity (JDBC). JDBC is used extensively in the sample programs in Chapter 11, XML and Databases. This primer will be a useful companion when you read Chapter 11, if you are not yet familiar with this API.

In the rest of this chapter, we first discuss Web applications and then give an overview of XML.

    [ directory ] Previous Section Next Section