World Wide Web Programming: Visualage for C++ and Smalltalk the Visualage Series
Total Page:16
File Type:pdf, Size:1020Kb
World Wide Web Programming: VisualAge for C++ and Smalltalk The VisualAge Series Bitterer, Brassard, Nadal, and Wong VisualAge and Transaction Processing in a Client/Server Environment Bitterer, Hamada, Oosthuizen, Porciello, and Rambek AS/400 Application Development with VisualAge for Smalltalk Bitterer and Carrel-Billiard World Wide Web Programming: VisualAge for C++ and Smalltalk Carrel-Billiard, Jakab, Mauny, and Vetter Object-Oriented Application Development with VisualAge for C++ for OS/2 Carrel-Billiard, Friess, and Mauny Programming with VisualAge for C++ for Windows Fang, Chu, and Weyerhäuser VisualAge for Smalltalk and SOMobjects: Developing Distributed Object Applications Fang, Guyet, Haven, Vilmi, and Eckmann VisualAge for Smalltalk Distributed: Developing Distributed Object Applications Nilsson and Jakab VisualAge for C++: Visual Programmer’s Handbook World Wide Web Programming: VisualAge for C++ and Smalltalk Andreas Bitterer Marc Carrel-Billiard INTERNATIONAL TECHNICAL SUPPORT ORGANIZATION SAN JOSE, CALIFORNIA 95120 PRENTICE HALL PTR UPPER SADDLE RIVER, NEW JERSEY 07458 Library of Congress Cataloging-in-Publication Data Bitterer, Andreas. World Wide Web programming with VisualAge for C++ and Smalltalk / Andreas Bitterer and Marc Carrel-Billiard p. cm. -- (The VisualAge series) Includes index. ISBN 0-13-612466-6 1. Internet programming. 2. VisualAge. 3. C++ (Computer program language). 4. Smalltalk (Computer program language). I. Carrel-Billiard, Marc II. Title. III. Series. QA76.625.855 1997 005.2 ’ 76--dc21 97-24152 CIP Copyright International Business Machines Corporation 1998. All rights reserved. Note to U.S. Government Users — Documentation related to restricted rights — Use, duplication, or disclosure is subject to restrictions set forth in GSA ADP Schedule Contract with IBM Corp. This edition applies to VisualAge for Smalltalk, Professional Version 3.0a, and VisualAge for C++, Version 3.5, and to all subsequent releases and modifications until otherwise indicated in new editions. Comments about ITSO Technical Bulletins may be addressed to: IBM Corporation ITSO, Almaden Research Center, QXX/80-E2, 650 Harry Road, San Jose, California 95120-6099 Published by Prentice Hall PTR Prentice-Hall, Inc. A Simon & Schuster Company Upper Saddle River, NJ 07458 The publisher offers discounts on this book when ordered in bulk quantities. For more information, contact: Corporate Sales Department, Prentice Hall PTR, One Lake Street, Upper Saddle River, NJ 07458 Phone: 800-382-3419; Fax: 201-236-7141; email: [email protected] Acquisitions Editor: Michael E. Meehan Manufacturing Manager: Alexis R. Heydt Cover Design: Andreas Bitterer, Design Source Copy Editors: Shirley Hentzell, Maggie Cutler Production Supervision: Kerry Reardon Cover Photograph: NASA Printed in the United States of America 10 9 8 7 6 5 4 3 2 1 ISBN 0-13-612466-6 Prentice-Hall International (UK) Limited, London Prentice-Hall of Australia Pty. Limited, Sydney Prentice-Hall Canada Inc., To r o n t o Prentice-Hall Hispanoamericana, S.A., Mexico Prentice-Hall of India Private Limited, New Delhi Prentice-Hall of Japan, Inc., To ky o Simon & Schuster Asia Pte. Ltd., Singapore Editora Prentice-Hall do Brasil, Ltda., Rio de Janeiro To the members of : Didi (Pharaoh), Hägar (Mountaineer), Mathew (Detective), and HaPe (Captain), for the great time on and off the stage. Watch out for those falling cactuses! A.B. To Tammy and Neil and our unfailing friendship. To the philosophers, their chopsticks, and all the people with whom I had fun teaching around the world. If you visit Tokyo, steer clear of ! M.C. Foreword Application development has dramatically changed in the last several years. In just a few evolutionary steps, programming has shifted from host-based green-screen applications, to workstations and PCs with graphical user interfaces and a client/server architecture, to the Internet, the World Wide Web, and its browser interface. Applications are no longer slated to run only on the desktop; they now run on Web servers throughout the Internet and company intranets. As an application user, you do not install an application. Instead, you simply point your favorite Web browser to a Web site and launch the application from there. In this book, you will learn how to leverage IBM application development products such as VisualAge for Smalltalk and VisualAge for C++, along with their Web Connection technology, and how to rapidly deploy sophis- ticated Web applications from prefabricated parts. The Web Travel Agent sample application is built through visual programming and includes relational database access, dynamic Web pages using the Common Gate- way Interface, multimedia, and Java. The authors walk you through the full application development cycle, from object-oriented analysis and design to implementation and packag- ing. They present the sample application in two flavors, which are based on the same design and access the same DB2 database. So, whether you are a C++ or Smalltalk programmer, this book will help you come closer to your own first application on the Web. The CD-ROMs that accompany the book contain Windows trial versions of IBM’s VisualAge for Smalltalk, VisualAge for C++, Database 2, Inter- net Connection Server, and the Web Travel Agent sample application. Install them on your own system and give them a try. Welcome to the world of Web programming! John Patrick Vice President – Internet Technology IBM Corporation vi Preface This book demonstrates how to use VisualAge for C++ and VisualAge for Smalltalk for the creation of object-oriented World Wide Web (WWW) applications. The reader learns to visually develop parts to build web pages that interact with underlying business logic and databases. A case study of the (fictional) Web Travel Agency (WTA) guides the reader through the steps of analysis, design and implementation of a sample web application that uses the Common Gateway Interface to communi- cate between HTML pages and VisualAge. All necessary parts and con- nections between them are explained, and all design considerations are covered in detail. To demonstrate portability and to show different application platforms, the Smalltalk version of the WTA was implemented in OS/2, the corre- sponding C++ version was implemented under Windows 95. This book explains how to use DB2 for OS/2 or DB2 for Windows 95/NT as database for application data through the VisualAge database parts, and also as server for the DB2 WWW Connection gateway. The Web Travel Agent provides the business logic, interfaces with a DB2 relational database, and generates HTML pages dynamically through the Common Gateway Interface. The VisualAge Web Connection parts are exploited to develop a Smalltalk application, that is based on the Visual Modeling Technique (VMT). World Wide Web Programming: VisualAge for C++ and Smalltalk was written for webmasters and web application programmers who want to extend their WWW presence through the use of object-oriented applications, and for VisualAge for C++ or Smalltalk developers looking for ways to add a WWW interface to their DB2 databases and object-oriented applications. Some knowledge of object-oriented programming with C++ or Smalltalk, the Structured Query Language (SQL), and HTML scripting is assumed. On the enclosed CDROMs we provide you with Windows trial versions of VisualAge for Smalltalk, VisualAge for C++, IBM Internet Connection Server, and DB2, along with the sample Web Travel Agent application. This application may serve as a base for testing your own setup and can easily be expanded and adapted to match your environment. vii How This Book Is Organized How This Book Is Organized This book consists of two parts. In Part 1, we set the stage for Web appli- cation development using IBM VisualAge products. We introduce the Web programming environment and the used development tools. In Part 2, we describe a real-world case study by going through the development steps of analysis, design, prototyping, and implementation. We also cover installation, configuration, and packaging issues. In some more detail, the book is organized as follows: Part 1, “VisualAge and the World Wide Web” ❑ Chapter 1, “Introduction and Overview” This chapter introduces the World Wide Web development environ- ment and describes the Common Gateway Interface. ❑ Chapter 2, “VisualAge Web Development Directions” This chapter contains a description of the various Web models and the VisualAge support for the models. We explain how the VisualAge product family can be leveraged for Web application development. ❑ Chapter 3, “VisualAge for Smalltalk Web Connection” In this chapter, we describe the Web Connection Feature of the Visu- alAge for Smalltalk product. We demonstrate how VisualAge inter- acts with the Web server through CGI Link. We also show examples of using visual and nonvisual parts to create Web pages. ❑ Chapter 4, “VisualAge for C++ Web Parts” In this chapter, we introduce the VisualAge for C++ Web Parts beta code also known as Waikiki. We describe the extensions of the User Interface Classes Library which supports CGI programming. We demonstrate different techniques to create static and dynamic Web pages. ❑ Chapter 5, “Introduction to DB2 World Wide Web Connection” In this chapter, we describe the DB2 World Wide Web Gateway. We explain how regular HTML can contain SQL statements to quickly create Web pages with database access. Part 2, “Case Study: Web Travel Agent” ❑ Chapter 6, “Analysis and Design” In this chapter, we describe the analysis and design steps for the Web Travel Agent application. We demonstrate how to use the Visual Modeling Technique with CRC cards, use cases, and various dia- grams. viii World Wide Web Programming with VisualAge for C++ and Smalltalk How This Book Is Organized ❑ Chapter 7, “Application in Action” In this chapter, we navigate through some sample threads of the Web Travel Agent application. We show how a user could book a travel package from the Web browser. ❑ Chapter 8, “Implementation with VisualAge for Smalltalk” In this chapter, we describe the implementation of the Web Travel Agent application using VisualAge for Smalltalk. We explain all major parts and their interactions with each other.