JSP and XML: From Web Services to XML in Your JSP Application
Authors: Casey Kochmer, Erica Frandsen
Venue:  (2002)

From the Book:The purpose of this book is to teach you how to implement XML and Web services within a JSP Web application or site. The book will start very simply and then work its way up in complexity. This will make the book accessible to a wide range of readers.The target audience includes new and intermediate JSP programmers. However, this book will be useful for any JSP programmer who wants to expand his or her XML or Web service implementation knowledge. The book is also geared towards helping a JSP programmer think in terms of the combination of JSP, XML, and Web services. The goal is to show how to usefully integrate these technologies into your projects and share the lessons we have learned in building Web applications.On XMLWe are programmers who spend quite a bit of time building Web applications. Over the past few years, we have been implementing XML in our projects. However, implementing XML is easier said than done at times. Even worse, many times XML is implemented in ways that can be harmful to a project. You should never use XML for XML's sake. This book is a reflection of our ordeals in learning the various tools and the methods of incorporating XML in a useful way into a Web site.The problem for developers hasn't been about finding information on XML, but about using XML successfully within Web applications. While there are plenty of solid XML titles, no title really focuses on how to integrate XML into your JSP project. This book is written with the JSP developer in mind. We want to help teach XML, XSL, XPath, and the entire alphabet soup that goes along with XML. By showing how to use XML within a JSP framework, we intend to help makeimplementing XML both easy and advantageous for the JSP developer.On Web ServicesWeb services are the latest fad. They are so new that many of the accompanying tools are still in beta or are only now being released into the marketplace. It's still very early to learn Web services. Web services are too new for anyone to truly be an expert in the field. This makes learning Web services both an exciting and a strange experience. Our intention is to teach you how to incorporate Web services into JSP. We will remove the confusion that surrounds Web services and give a clear path to learning the basics. This book will show the various elements that constitute a Web service.On the Structure of the BookThe book is divided into four parts. Part I is designed to introduce you to each of the technologies exemplified throughout this book. Part II drills deeply into the various tools for each of these technologies. Part III shows how to successfully combine all these technologies to make your project easier and faster to implement. Part IV contains appendixes that provide reference material.Part I: Data, XML, and Web Services IntroductionThis part is intended to ground you. We do not assume that you already know a great deal about JSP, XML, or Web services; these three topics are introduced in Chapters 1-3.Chapter 1: Integrating JSP and DataThis chapter shows how to use JSP and a database together. The chapter serves to ground you in JSP and show you how to perform basic database connectivity.Chapter 2: Introduction to XML/XSLThis chapter is a whirlwind tour of XML and XSL. It introduces each of the major concepts that are needed for XML and begins teaching XSL and XPath.Chapter 3: Understanding Web ServicesChapter 3 introduces the concepts of Web services. Web services are a confusing topic, and the chapter focuses on the basic concepts you will need to use them.Part II: Integrating JSP and XMLPart II is a review of the tools, APIs, and logic required to successfully implement XML and Web services. These chapters introduce the various concepts of Web services and the various parsers for XML. Once you've studied these chapters, you will have enough knowledge to begin using XML and Web services successfully.Chapter 4: A Quick Start to JSP and XML TogetherThis chapter gives you a quick start to mixing JSP and XML together. The chapter reviews the basic XML APIs and works through some examples of merging JSP and XML.Chapter 5: Using DOMThis chapter teaches the important aspects of the DOM API. The DOM is the standard supported by the W3C for working with an XML file programmatically.Chapter 6: Programming SAXThis chapter teaches you the ins and outs of the SAX API. SAX is probably the most common API used to read in an XML file. Most of the time, SAX is used automatically by other XML APIs. However, this chapter is very important because understanding SAX is critical for handling more complicated XML-based processes. Chapter 7: Successfully Using JSP and XML in an ApplicationThis chapter introduces the other major Java XML APIs: JDOM and dom4j. This chapter produces an integrated example showing how to work with JSP, XML, and a database. The goal of this chapter is to begin walking you through the integration of XML in a natural way within your JSP application.Chapter 8: Integrating JSP and Web ServicesChapter 8 examines how to use a Web service within your JSP site. This chapter covers two important Web services topics. The first is using a Web service; the chapter shows the most efficient way to use a Web service within your JSP application. The second topic is building a Web service; the chapter walks through the creation of a Web service that can be used by other applications.Chapter 9: Advanced JSP and XML TechniquesThis chapter explores XML concepts that aren't discussed in other chapters. Topics include accessing a Web service from an HTML page, XML encoding issues, ways of processing large XML documents, and XML tag libraries.Part III: Building JSP Sites to Use XMLBuilding a JSP site requires far more than just knowing how to use JSP. It requires the ability to think in terms of building a Web application. Web application design is a fine art that involves integrating many different tools as a seamless unit within a JSP project. To this end, Part III covers the implementation of XML and Web services from an application point of view. The chapters in this part cover many topics, from Web service security to building XML reporting systems. We show many different facets of Web application design, from the server to the often-overlooked browser client.Chapter 10: Using XSL/JSP in Web Site DesignThis chapter examines what is possible by going back to the roots of JSPor more specifically by using servlets. The goal of the chapter is to examine generic XML handling. This means that the initial processing of an XML document can happen at the application level rather than at the page level. The chapter shows how to capture the processing of an XML page and route it directly to a servlet.Chapter 11: Using XML in Reporting SystemsNo matter what the Web application, it's a safe bet that there will be some reporting involved. This chapter examines how reporting systems can benefit from the appropriate placement and use of XML.Chapter 12: Advanced XML in Reporting SystemsThis chapter builds on the examples in Chapter 11. Additional concepts and topics to enhance an XML-based reporting system are shown in this chapter's examples. Among the examples is one that shows how to create reports that show a one-to-many relationship in the database.Chapter 13: Browser Considerations with XMLJSP developers often overlook client-side XML processing. This is a serious oversight, as browsers are a growing and improving XML client-side tool. This chapter examines how using the browser can enhance handling of XML data and reduce Web server load.Chapter 14: Building a Web ServiceIn this chapter, we build a Web service system for news delivery. The code within this chapter is based on a Web service within a production environment. The goal is to show the design and full integration of a complete Web service.Chapter 15: Advanced Application DesignThis chapter covers two topics. First, we'll show you how to build JSP pages that update themselves. This advanced capability permits JSP sites to be more flexible and to expand what is possible with XML, Web services, and JSP. The second main topic is security; the chapter examines how to secure your Web services.AppendixesThe appendixes support the material presented in the main part of the book. Their contents are briefly described here.Appendix A: Setting UpThis appendix covers basic information about setting up the JSP container and introduces NetBeans for the creation of all your JSP pages.Appendix B: Introduction to JSP and How Things WorkFor new JSP users, this appendix offers a crash course on JSP and how it works.Appendix C: Tag LibraryThis book uses JSP tag libraries as much as possible. For users who are new to JSP, this appendix quickly covers how to build and use a JSP tag library.Appendix D: XSL ReferenceXSL is used extensively in this book. Appendix D is a reference to the most commonly used XSL tags and XPath functions.A Word about Source CodeAll the source code from the listings and programs included in this book is available via download.Throughout the book, we create sample class files and JSPs and then build on them later in the same or another chapter. Whenever we do so, we clearly indicate where the original file can be found. Lines of code that should be added or changed are indicated in boldface type.How to Use the BookAs we mentioned earlier, this book is geared toward new and intermediate JSP programmers. How you use the book, and where you begin reading, will depend on your experience level. Here are a few tips to get you started.For All UsersIf possible, we recommend coding the examples. In programming, the best way to learn is by coding, and the examples have been geared to enable you to do so. If you have any questions about initially setting up the JSP container or NetBeans to create JSPs, refer to Appendix A. Otherwise, the first time a specific component is used, it will be referenced for installation at that time.In many respects, coding the examples is very important because this book explores many different concepts. If you don't write the code, many of the concepts are likely to slip by or not sink in as deeply as they should. We also encourage you to expand and tweak the examples. Try to break the code and find out why it breaks. As programmers, we learn best by coding and by fixing broken code. Coding is best learned by experience; don't shy away from this reality.For New JSP UsersWe are not going to assume that you already know JSP like the back of your hand. Someone with little or no JSP experience can pick up this book and learn how to use JSP and XML. The code and topics are built in a logical and easy manner to help show what is required in using XML within your JSP projects. Beginning JSP programmers will want to study the chapters in Part I closely. The examples are simple enough that they will be a great learning aid. New JSP readers will also benefit from reading Appendix B.For Intermediate JSP UsersThe best starting place will depend on your skills. For users who are inexperienced in XML or Web services, Part I is still your best bet. Otherwise, we recommend skimming the first section, as there is quite a bit of information within each chapter. These chapters have some information that can benefit more experienced readers. However, if you find that you already know the Part I material, skip ahead to Part II.Conventions Used in This BookThe following typographic conventions are used in this book: Code lines, commands, statements, variables, and any text you type or see onscreen appears in a mono typeface. Placeholders in syntax descriptions appear in an italic mono typeface. Replace the placeholder with the actual filename, parameter, or whatever element it represents. Italics highlight technical terms when they're being introduced and defined. The book also contains Notes to help you spot important or useful information more quickly.A Final NoteThis book was written as a reference for JSP, XML, and Web services. Learning this material on our own was a long process, and our goal is to help give JSP developers some insights into building JSP Web applications. The fact is, XML and Web services are both fast becoming essential tools to most JSP applications. The problem is trying to learn everything at once. Our goal was to provide integrated examples of practical JSP, XML, and Web service implementations. We hope that you benefit from reading the book as much as we benefited from writing it.