DEVELOPING

         Intranet Applications with Java


by Jerry Ablan



C  O  N  T  E  N  T  S


Introduction

I
Planning an Intranet

Chapter 1  Intranets and Java

Chapter 2  Designing Intranet Applications with Java

Chapter 3  Planning Your Intranet Environment

II
Development Concepts and Environments

Chapter 4  Java Development Environments

Chapter 5  Intranet Security

Chapter 6  Database Connectivity Options

III
Extending Java for Intranets

Chapter 7  A Model Intranet Application

Chapter 8  Utility Classes

Chapter 9  Logging Classes

Chapter 10  Database Classes

Chapter 11  User Interface Classes

Chapter 12  Putting Them All Together

IV
Applications Developing with JIF

Chapter 13  Employee Files

Chapter 14  Human Resources: Benefits Maintenance

Chapter 15  Conference Room Scheduling

Chapter 16  Online In/Out Board

Chapter 17  Online Employee Phonebook

Chapter 18  News & Announcements

Chapter 19  Product Maintenance

Chapter 20  Customer Support Maintenance

Chapter 21  Extending the Java Intranet Framework

appendixes

appendix A  Java Resources

appendix B  JDK Tools Reference

appendix C  Java API Reference

appendix D  Java Class Reference

appendix E  Differences Between Java and C/C++

appendix F  Java Intranet Framework Reference

appendix G  What's on the CD-ROM



Credits



To Kathryn. A dedication haiku:
"Love is a great thing, like puddles after the rain, or a stroll with you."
-Jerry Ablan

Copyright © 1996 by Sams.net Publishing

FIRST EDITION

All rights reserved. No part of this book shall be reproduced, stored in a retrieval system, or transmitted by any means, electronic, mechanical, photocopying, recording, or otherwise, without written permission from the publisher. No patent liability is assumed with respect to the use of the information contained herein. Although every precaution has been taken in the preparation of this book, the publisher and author assume no responsibility for errors or omissions. Neither is any liability assumed for damages resulting from the use of the information contained herein. For information, address Sams.net Publishing, 201 W. 103rd St., Indianapolis, IN 46290.

International Standard Book Number: 1-57521-166-1

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

Trademarks

All terms mentioned in this book that are known to be trademarks or service marks have been appropriately capitalized. Sams.net Publishing cannot attest to the accuracy of this information. Use of a term in this book should not be regarded as affecting the validity of any trademark or service mark.

Java is a trademark of Sun Microsystems, Inc.


President, Sams Publishing Richard K. Swadley
Publishing Manager Mark Taber
Managing Editor Cindy Morrow
Director of Marketing John Pierce
Assistant Marketing Managers Kristina Perry, Rachel Wolfe


Acquisitions Editor Beverly M. Eppink Development Editor Kelly Murdock
Software Development Specialist Bob Correll Production Editors Mary Inderstrodt, Ryan Rader
Copy Editors Brice Gosnell, Stacey Houston,Kristen Ivanetich, Howard Jones
Indexer Johnna VanHoose Technical Reviewers Will Kelly, Billy Vernon
Editorial Coordinator Bill Whitmer Technical Edit Coordinator Lorraine Schaffer
Resource Coordinator Deborah Frisby Editorial Assistants Carol Ackerman, Andi Richter, Rhonda Tinch-Mize
Cover Designer Tim Amrhein Book Designer Alyssa Yesh
Copy Writer Peter Fuller Production Team Supervisor Brad Chinn
Production Debra Bolhuis, Mona Brown, Kevin Cliburn, Betsy Deeter, Jason Hand, Susan Knose, Clint Lahnen, Carl Pierce, Casey Price, Laura Robbins, Ian Smith, Susan Van Ness, Marvin Van Tiem


Acknowledgments

Thanks to Sun Microsystems for creating a very cool language!

Thanks to the people at Sams-most importantly, Beverly Eppink. This book would not have been possible without the idea she originally gave to me. I'd also like to thank Kelly Murdock for keeping me, and the book, on track. Thanks!!

I'd like to thank my Internet Service Provider (again!) for providing me with excellent Internet service throughout the writing process. Thanks to Karl Denninger and the folks at MCSNet in Chicago. Keep up the good work!

Thanks to all my friends at work who helped and encouraged me, especially Eric Reiner and Nick Athanas. Thanks also to Maureen Smith for putting up with me while I did this again!

I'd also like to thank my close friends. With their support, I was able to hide in my office at home and write. I missed many good Friday evenings at George and Alex's because of this book. So thanks to Tom and Nancy Lynch, Tom and Karen Kenny, George Walker, Alex Weismantel, and Jim Burck. (Have I been more sociable lately, Alex?)

I'd like to thank my animals for staying out of my hair: Grendl (Great Dane), Cecil (Dachshund), Buttons (Calico Cat), T.C. (Tabby Cat), and Kato (Tabby Cat).

Lastly, I'd like to thank my wife. Without her support, an endeavor such as this would not be possible. Thanks, Kathryn!

Jeen Velly

                                          & nbsp;                                           ;                                          &nb sp;                                          & nbsp;                                         -Jerry Ablan

About the Author

Jerry Ablan (munster@mcs.net) is best described as a computer nut. Jerry has been involved in computers since 1982. He has worked on and owned a variety of microcomputers including several that are no longer manufactured. He has programmed in many languages, including several that are not cool (such as RPG II). Jerry is a Senior Software Engineer at the Chicago Board Options Exchange. There he creates client/server systems for IBM, HP, and microcomputer platforms. He (and his wife) can't believe that people pay him money to program computers!

Jerry is a member of TeamJava (http://www.teamjava.com), the Java Developer's Organization (http://www.jade.org), and the Illinois Java User's Group (http://www.xnet.com/~rudman/java.html). The Chicago Java User's Group was a little too snooty for him.

Jerry lives in a Chicago suburb with his wife Kathryn, their two dogs (Grendl and Cecil), three cats (Uncle Pat, T.C., and Kato), and a tank full of fish. When not working, writing, or otherwise cavorting, Jerry and his brother Dan (dma@mcs.net) operate NetGeeks (http://www.netgeeks.com), an Internet consulting firm in Chicago, Illinois.

Jerry is coauthor of the Web Site Administrator's Survival Guide from Sams.net and a contributing author to Using Java and Platinum Edition: Using HTML, Java, and CGI from Que, as well as Java Unleashed and Intranets Unleashed from Sams.net.

William R. Stanek (director@tvp.com) is a leading Internet technology expert and a working professional who directs an Internet start-up company called The Virtual Press (http://tvp.com/ and mirror site http://www.tvpress.com/). As a publisher and writer with over 10 years experience on networks, Stanek brings a solid voice of experience on the Internet and electronic publishing to his many projects. He has been involved in the commercial Internet community since 1991 and was first introduced to Internet e-mail in 1988 when he worked for the government. His years of practical experience are backed by a solid education, Master of Science in Information Systems and a Bachelor of Science in Computer Science. In addition to authoring best-sellers such as Sams.net's Web Publishing Unleashed and Microsoft FrontPage Unleashed, Stanek advises corporate clients and develops hot new Web sites.

Rogers Cadenhead (rcade@airmail.net) is a Web developer, computer programmer, and writer who created the multiuser games Czarlords and Super Video Poker. Coauthor of Teach Yourself SunSoft Java Workshop in 21 Days, he also writes an advice column, "Ask Ed Brice," in the Fort Worth Star-Telegram, and has programmed Java applications for Tele-Communications, Inc. and other clients.

Tell Us What You Think!

As a reader, you are the most important critic of and commentator on our books. We value your opinion and want to know what we're doing right, what we could do better, what areas you'd like to see us publish in, and any other words of wisdom you're willing to pass our way. You can help us make strong books that meet your needs and give you the computer guidance you require.

Do you have access to CompuServe or the World Wide Web? Then check out our CompuServe forum by typing GO SAMS at any prompt. If you prefer the World Wide Web, check out our site at http://www.mcp.com.

Note

If you have a technical question about this book, call the technical support line at (800) 571-5840, ext. 3668.

As the team leader of the group that created this book, I welcome your comments. You can fax, e-mail, or write me directly to let me know what you did or didn't like about this book-as well as what we can do to make our books stronger. Here's the information:

Fax: (317) 581-4669
E-mail: newtech_mgr@sams.mcp.com
Mail: Mark Taber
Comments Department
Sams Publishing
201 W. 103rd Street
Indianapolis, IN 46290


Introduction

Welcome

Hello, and welcome to Developing Intranet Applications with Java. I hope you enjoy this book as much as I enjoyed writing it. This is a book that represents a lot of work in the area of Java application programming and design. It is designed to hold your hand while you journey through the hills and valleys of Java application programming. You needn't be creating Intranet applications specifically to use this book. It does, however, focus on corporate and Intranet application development. More importantly, its focus is Java application programming. Even though the applications might not be your cup of tea (or coffee!), the concepts and source code presented in this book will be of value.

After reading this book, you should have a good understanding of programming Java applications and how to apply that toward creating applications of your own, Intranet-specific or not. This knowledge will help you at work or at play, but most of all it will help you be a better Java programmer and provide you with a rich source code base to use as your coding foundation.

Who Should Read This Book

Although this book is geared toward experienced programmers, beginning programmers will find it useful as well. However, you should have some experience with C, C++, or Java. It would help if you had some database programming experience as well.

How This Book Is Designed

This book is divided into four distinct parts. I'll go over each section in detail and give you a little background on its purpose and content.

Part I: Planning an Intranet

The first part gives you a little background information on intranets. Many readers might not be familiar with the term intranet and its implications. Some of the topics covered in this section are

After finishing the first part of this book, you should have some good, solid knowledge about integrating Java applications into your intranet plans. You will also gain a little insight about developing intranet applications.

Part II: Development Concepts and Environments

This part examines some of the more pressing issues in intranet development with Java. Areas covered in this section are

Part III: Extending Java for Intranets

This part introduces you to an application framework for building intranet applications. This framework is called JIF. JIF stands for Java Intranet Framework. JIF is a made up of several Java packages and is included on the CD-ROM. You can use JIF to create your own applications, or you can modify it for your own needs. It's up to you!

This section covers the foundations of a framework and builds upon it. Before any classes are discussed, however, a model intranet application is presented. This application becomes the driving force of the class creation for the rest of this section. It is also the model used for the sample applications in the next section.

Part IV: Applications Development with JIF

This section presents eight sample intranet applications. These applications are real-world examples of using Java to create database-aware intranet applications. The applications presented are

These are fully functioning applications that really do work! The source code for them is included on the CD-ROM.

Conventions Used in This Book

The following type conventions are used throughout this book:

Italic type is used for

Monospaced type is used for

Monospaced Italic type is used for

There are also some special conventions used when discussing parameters of classes and functions in their declarations. These conventions are similar to most other programming books that you've seen. They are as follows:

Note

Throughout this book I use several terms interchangeably.
Specifically the terms object and class, and the terms application and program.
Some say that an object is only an instantiation of a class. However, I feel that a class is an object in any stage of life. So, don't be too mad.
Also, you will see the terms method and function used to refer to the same thing, as well as member and instance variable. They all mean the same things; however, different books call them different things. I have no idea what you, the reader, call them, so I'm trying to please everyone.