Skip to main content.

Web Based Programming Tutorials

Homepage | Forum - Join the forum to discuss anything related to programming! | Programming Resources

Java Expert Solutions

CONTENTS

JAVA

Expert Solutions

by Mark Wutka, et. al.


C  O  N  T  E  N  T  S




Introduction

Chapter 1    What Is Java?



Chapter 2    Embedding Applets in Web Pages

Chapter 3    Applet Security Restrictions

Chapter 4    Displaying Images

Chapter 5    Animating Images



Chapter 6    Communicating with a Web Server

Chapter 7    Creating Smarter Forms

Chapter 8    Reading and Writing Files from an Applet

Chapter 9    Creating Reusable Graphics Components

Chapter 10    Inter-Applet Communication

Chapter 11    Sending E-Mail from an Applet

Chapter 12    Protecting Applet Code

Chapter 13    Running Applets as Applications

Chapter 14    Creating Your Own Class Archive Files

Chapter 15    Accessing Databases with JDBC

Chapter 16    Creating 3-Tier Distributed Applications with RMI

Chapter 17    Creating CORBA Clients

Chapter 18    Using CORBA IDL with Java

Chapter 19    Creating CORBA Servers

Chapter 20    Increasing Graphics Performance

Chapter 21    Download Strategies

Chapter 22    Faster Image Downloads

Chapter 23    Creating Web Services in Java

Chapter 24    Writing Web Services for Jeeves

Chapter 25    Writing Web Services for Jigsaw

Chapter 26    Securing Applets with Digital Signatures

Chapter 27    Encrypting Data

Chapter 28    Accessing Remote Systems Securely

Chapter 29    Creating a Java Shopping Cart

Chapter 30    Performing Secure Transactions

Chapter 31    Java Electronic Commerce Framework (JECF)

Chapter 32    Encapsulating Legacy Systems

Chapter 33    Web-Enabling Legacy Systems

Chapter 34    Interfacing with CICS Systems

Chapter 35    Adding Additional Protocols to HotJava

Chapter 36    Adding New MIME Types to HotJava

Chapter 37    Creating Multi-User Programs in Java

Chapter 38    Creating On-Demand Multimedia Services

Chapter 39    Implementing a Multimedia Encyclopedia

Chapter 40    Implementing Java Interfaces for Non-Traditional Devices


Credits


Java Expert Solutions

Copyright 1997 by Que © Corporation.

All rights reserved. Printed in the United States of America. No part of this book may be used or reproduced in any form or by any means, or stored in a database or retrieval system, without prior written permission of the publisher except in the case of brief quotations embodied in critical articles and reviews. Making copies of any part of this book for any purpose other than your own personal use is a violation of United States copyright laws. For information, address Que Corporation, 201 W. 103rd Street, Indianapolis, IN 46290. You may reach Que's direct sales line by calling 1-800-428-5331.

ISBN: 0-7897-0935-x


HTML conversion by :
    M/s. LeafWriters (India) Pvt. Ltd.
    Website : http://leaf.stpn.soft.net
    e-mail : leafwriters@leaf.stpn.soft.net


PresidentRoland Elgey PublisherJoseph B. Wikert
Publishing Manager Jim Minatel Title ManagerSteven M. Schafer
Editorial Services Director Elizabeth Keaffaber Managing Editor Sandy Doell
Director of Marketing Lynn E. Zingraf Acquisitions Manager Cheryl D. Willoughby
Acquisitions Editor Stephanie Gould Product Directors Mark Cierzniak, Jon Steever
Production Editor Sean Dixon EditorsKelly Brooks, Judith Goode, Sidney Jones, Kelly Oliver
Product Marketing Kim Margolius Assistant Product Marketing Manager Christy M. Miller
Strategic Marketing Manager Barry Pruett Technical Editors Jim Hoffman, Russ Jacobs, Ernie Sanders, Eugene W. Sotirescu, Steve Tallon
Technical Support Specialist Nadeem Muhammed Acquisitions Coordinator Jane K. Brownlow
Software Relations Coordinator Patty Brooks Editorial Assistant Andrea Duvall
Interior Book Designer Barbara Kordesh Cover Designer Barbara Kordesh
Production Team Kevin Cliburn, Tammy Graham, Jason Hand, Heather Howell, Dan Julian, Bob LaRoche, Casey Price, Erich Richter, Laura Robbins, Marvin Van Tiem, Paul Wilson
IndexerChris Barrick


Acknowledgments

Writing a book like this is quite an experience, and one of the most important parts of that experience has been the people I have worked with and the people who helped me get through it.

I would especially like to thank my wife Ceal, who somehow managed to keep me close to my normal level of sanity (which is minimal at best). Thanks also go to Chris, Amy, Samantha, and Kaitlynn, who had to endure endless hours of clicking keys and to my Mom, who taught me, by example, how to work hard and to strive constantly to improve myself.

Joe Weber, author of Special Edition Using Java, provided some excellent suggestions about the outline for this book, as well as some good advice about being an author. In addition, Cliff McCartney provided me with technical feedback on various aspects of the book, especially in the area of legacy system migration-a subject near and dear to both of our hearts.

This book was not written by a single person. I am extremely grateful for the work of the other authors. The technical expertise that each of them brought to this book has truly made it a book of expert solutions.

I would also like to thank the staff at Que, who have been great to work with-Stephanie Gould, Mark Cierzniak, Ben Milstead, Jon Steever, Sean Dixon, and the many people behind the scenes.

Finally, I would like to thank Geddy, Alex, and Neil for EXCELLENT music to code by. You guys have gotten me through hundreds of thousands of lines of code.


About the Authors

David W. Baker is a systems developer for BBN Planet, a business unit of BBN Corporation. He specializes in software development and system integration for Internet solutions. He also works as a freelance game writer, authoring materials for various roleplaying games. Until recently, he worked for Second Nature Interactive, a software development company, where he served as a Senior Game Writer. David's home page is available at http://www.netspace.org/users/dwb/.

David P. Boswell lives in Brigham City, Utah, with his wife Carma and four children. He works as a programmer/analyst for Thiokol Corporation and as an independent Internet consultant. David can be reached via http://www.daves.net or dave@daves.net.

Ken Cartwright is a software engineer with Science Applications International Corp. He has received a bachelor's degree from the University of Oklahoma and a master's degree in information systems and software engineering from George Mason University. He has been developing complex software systems for several years and has spent the last three years concentrating on object-oriented distributed system development using CORBA and object-oriented databases. Some of his most recent projects utilized the combination of Java and CORBA to support client/server systems. Ken can be reached at KenCartwright@msn.com.

David Edgar Liebke (liebke@scripps.edu) works at The Scripps Research Institute in La Jolla, CA. A member of the Research Computing group, he develops Java-based information systems and deals with issues of network security. David graduated from UC San Diego with a B.S. in cognitive science, where he studied artificial intelligence, neural networking, and emergent computation. He currently lives in Irvine, CA with his spousal-type unit, Rochelle, who is completing her doctorate in cognitive science. David hopes to one day rid the world of tyranny, or at least proprietary software "standards."

Tom Lockwood has 12 years' experience as a technical writer and marketing specialist with several computer graphic companies. He is currently employed at Cinebase Software where he championed the development of its Web site. Tom is also a freelance writer, a softball coach, and, most proudly, an Aries. He can be reached at tom.lockwood@cinesoft.com or via his personal Web site at http://www.cris.com/~tlockwoo.

Stephen N. Matsuba is cofounder of Alt.Reality Technologies Corporation, a company developing virtual reality and multimedia applications, and SHOC Interactive, a company developing multimedia games and educational applications. In his other life, he is completing his Ph.D. in computational linguistics and English literature at York University, Canada. His research interests include Shakespeare, literary theory, computational linguistics, artificial intelligence and cognitive science, computer applications in humanities research and education, VR, and multimedia design. He also coauthored Special Edition Using VRML (Que, 1996) with Bernie Roehl.

George Menyhert is currently the Director of the Harmony Product and a member of the technical staff at Cinebase Software where he concentrates on multimedia application engineering. He is also a freelance Java developer. George has a degree in engineering from the University of Cincinnati. He can be reached via his Web page at http://w3.one.net/~menyhert or through one of his various e-mail accounts: george.menyhert@cinesoft.com, menyhert@one.net, or menyhert@acm.org.

Krishna Sankar has been a computer professional since 1980. He has worked on strategic business systems for companies like HP, AT&T, Pratt & Whitney, Testek, Ford, TRW, Caterpillar, Qantas Airlines, and Air Canada, as well as for the U.S. Air Force and U.S. Navy. He still believes in information re-engineering and development of competitive business systems and is excited about the possibilities of intranet applets and servlets in those areas. He has two master's degrees, one in production engineering and the other in computer science. He is now pursuing his MBA. He is a Microsoft Product Specialist as well as a Lotus Certified Professional. He is the founder of U.S. Systems & Services, a Silicon Valley intranet systems and Java technology company. Nowadays, you can meet him in the corridors of venture capitalists and banks promoting products "for those whose life is not Internet but want to leverage the net to enjoy it."

Mark Wutka is a senior systems architect who refuses to give up his programming hat. For the past two years he has worked as the chief architect on a large, object-oriented distributed system providing automation for the flight operations division of a major airline. Over the past eight years, he has designed and implemented numerous systems in C, C++, Smalltalk, and Java for that same airline.

He is currently the Vice President of Research and Development for Pioneer Technologies, a consulting firm specializing in distributed systems and legacy system migration. He can be reached via e-mail at wutka@netcom.com. He also claims responsibility for the random bits of humor found at http://www.webcom.com/wutka.


We'd Like to Hear from You!

As part of our continuing effort to produce books of the highest possible quality, Que would like to hear your comments. To stay competitive, we really want you, as a computer book reader and user, to let us know what you like or dislike most about this book or other Que products.

You can mail comments, ideas, or suggestions for improving future editions to the address below, or send us a fax at (317) 581-4663. Our staff and authors are available for questions and comments through our Internet site, at http://www.mcp.com, and Macmillan Computer Publishing also has a forum on CompuServe (type GO QUEBOOKS at any prompt).

In addition to exploring our forum, please feel free to contact me personally to discuss your opinions of this book: I'm mcierzniak@que.mcp.com on the Internet.

Thanks in advance-your comments will help us to continue publishing the best books available on new computer technologies in today's market.

Mark Cierzniak
Product Development Specialist
Que Corporation
201 W. 103rd Street
Indianapolis, Indiana 46290
USA


Introduction

by Mark Wutka

Java is one of the most significant software products to hit the scene in a long time. Unlike Netscape, whose impact was big and immediate, Java's full impact won't be realized for a long time. Java is more than just a programming language. It requires a different mindset when developing applications.

Sure, you can use Java to spruce up your Web pages-it works quite well for that. This book will even give you some tips on ways to do it. But that's not the main purpose of Java. If you only use it for pretty Web pages, you are missing a lot.

Hacking Java: The Java Professional's Resource Kit not only gives you lots of useful Java classes and programming tips, it relates the "vision" of Java. You get an overview from the 30,000-foot level, as well as from down in the trenches, to borrow some management clichés. Both of these views are important. When you're digging a trench, you still need to look up to see where you're headed. Java will have a significant impact on the future of software development, and even the future of technology. If you don't already understand why this is so, you need this book.

One of the important things to realize about Java is that it is young and still evolving. There are many features yet to come, and many more uses of Java to be discovered. This book will help guide you in making design decisions that may be affected by some of these new applications of Java.

Who Should Read This Book

This book addresses Java on several different levels. Some people will be interested in hard-core programming techniques. There are plenty of those here. You may know the language, but you want to use it to solve different problems that aren't addressed in any of the Java programming books.

You may be a software designer, looking for new design techniques. This book has plenty of good object-oriented design strategies that apply not only to Java but to other O-O languages as well.

If you're a system architect creating your company's information infrastructure, there's plenty in here for you, too. This book discusses many architectural issues and shows you situations where you can use Java that you've probably never thought of. This is especially true when it comes to the overall philosophy of Java and its multitude of uses.

This book is not an introduction to programming in Java. There is no discussion of what classes and methods are. Special Edition Using Java by Que will give you a good introduction to Java. This book is meant to complement Special Edition Using Java, giving you the kind of advice that you don't get from a book on programming.

What This Book Is About

Hacking Java: The Java Professional's Resource Kit is more than just a how-to book. It's also a what-to book. A how-to book assumes that you already know exactly what you want to do, and it gives you step-by-step instructions showing you how to do it. This book gives you ideas about what to do with Java, and then tells you how to implement them.

How This Book Is Organized

This book starts out by addressing some of the burning issues of creating applets. It provides suggestions for improving the performance of your applets, as well as ways to get around some of the restrictions imposed on applets.

Section II discusses some of the aspects of Java applications, including a way to run an applet as an application. This section also discusses the JDBC database interface and the remote method invocation facility.

Section III discusses some of the CORBA products available for Java, how to use them, and what you can do with them. If you are unfamiliar with CORBA, you also get a brief introduction to CORBA.

Section IV shows you how you can speed up your applets, both in the download phase and once the applet is running.

Section V introduces some of the Java Web servers that are now available. You can use Java to implement new Web services that you previously could only do with CGI. In addition, since the servers are written in Java, you can run them anywhere you can run Java.

Section VI delves into some of the deeper aspects of security. It introduces digital signatures and data encryption, and discusses some of the issues involved in protecting your communications.

Section VII shows you how you can use Java to do business over the Web. It discusses some of the aspects of electronic commerce and shows you how to perform secure transactions.

Section VIII deals with "legacy" systems and how you can use Java to connect these older systems to the Internet. There is a large amount of system design philosophy in this section, much of which is applicable no matter what language you are using.

Section IX shows you how to expand capabilities of the HotJava browser, which is written entirely in Java. You will learn how you can add new networking protocols and how you can make HotJava understand new data formats.

Section X introduces some of the multimedia capabilities of Java. This is one field where Java will be expanding greatly. This section suggests possible uses of Java in the multimedia realm.

Section XI discusses some of the issues involved with running Java on small devices like cellular phones and personal digital assistants (PDA). As these devices become more readily available, your systems will have to cooperate with them. This section gives you guidelines that let you start planning for these devices now.

On the CD, three chapters will show you how Java integrates with the Virtual Reality Markup Language (VRML). You will see how you can add whole new dimensions to your Java programs, literally.

How to Use This Book

You can use this book either as a cookbook or as a learning tool. If you have a specific problem that you need to solve, you can consult the book for the solution, as you might use a reference book.

This book is also of immense use as a learning tool. It covers issues faced every day by professional programmers. These issues are rarely covered in a typical programming book.

While many of the example programs solve complex problems, you will find most of them to be relatively straightforward. If you are still fairly new to programming, you will learn a lot just by studying the example programs. They are fairly well-commented and are quite readable.