DEVELOPING

Intranet apps 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 apps 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 app

Chapter 8 Utility Classes

Chapter 9 Logging Classes

Chapter 10 Database Classes

Chapter 11 User Interface Classes

Chapter 12 Putting Them All Together

IV
apps 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



1996 by Sams.net Publishing

FIRST VERSION

All rights reserved. No part of this tutorial shall be reproduced, stored in a retrieval system, or transmitted by any means, electronic, mechanical, photocopying, recording, or otherwise, without written permission from the uploader. 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 tutorial, the uploader 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 tutorial 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

things

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


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 Oracle for creating a very cool language! Thanks to the people at Sams-most importantly, Beverly Eppink. This tutorial 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 tutorial, 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 tutorial. 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 version: Using HTML, Java, and CGI from Que, as well as Java Unleashed and Intranets Unleashed from Sams.net. William R. Stanek (director@bugmenot.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 uploader 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 apps 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 tutorials. 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 tutorials 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 tutorial, call the technical support line at (800) 571-5840, ext. 3668.


As the team leader of the group that created this tutorial, 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 tutorial-as well as what we can do to make our tutorials 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 apps with Java. I hope you enjoy this tutorial as much as I enjoyed writing it. This is a tutorial that represents a lot of work in the area of Java app coding and design. It is designed to hold your hand while you journey through the hills and valleys of Java app programming. You needn't be creating Intranet apps specifically to use this tutorial. It does, however, focus on corporate and Intranet app development. More importantly, its focus is Java app programming. Even though the apps might not be your cup of tea (or coffee!), the concepts and source code presented in this tutorial will be of value. After reading this tutorial, you should have a good understanding of coding Java apps and how to apply that toward creating apps 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 tutorial

Although this tutorial 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 coding experience as well.

How This tutorial Is Designed

This tutorial 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 tutorial, you should have some good, solid knowledge about integrating Java apps into your intranet plans. You will also gain a little insight about developing intranet apps.

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 app framework for building intranet apps. 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 apps, 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 app is presented. This app becomes the driving force of the class creation for the rest of this section. It is also the model used for the sample apps in the next section.

Part IV: apps Development with JIF

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

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

Conventions Used in this tutorial

The following type conventions are used throughout this tutorial: 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 coding tutorials that you've seen. They are as follows:

Note

Throughout this tutorial I use several terms interchangeably.
Specifically the terms object and class, and the terms app 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 tutorials call them different things. I have no idea what you, the reader, call them, so I'm trying to please everyone.



Java ScreenshotJava Screenshot



Comments