You are previewing Advanced JAVA Networking.
O'Reilly logo
Advanced JAVA Networking

Book Description

Super-charged network solutions for experienced Java professionals, updated to Java 2

  • Create powerful client/server applications with RMI

  • Use IDL to build CORBA applications that work with legacy systems

  • Interface with databases using JDBC and SQL

  • Completely updated from the best-selling first edition

  • The latest in Java: JDBC, JINI, JMAPI, IDL, and CORBA

  • Up-to-date networking: TCP/IP, RMI, sockets

  • Application servers, Web servers, and servlets

  • Directory Services, LDAP, and JNDI

  • Advances in Java security

  • Java remains the language of choice for building Internet and networked applications. In this completely updated second edition of the 1997 best seller, Dick Steflik and Prashant Sridharan bring you tips on the hottest new developments in Java and its family of technologies. For seasoned programmers who need to stay current on Java for network applications, this is the book with the answers.

    Java is the first programming language created with the Internet in mind, and this book shows you how it optimizes networked applications with such architectural elements as multithreading, serialization, and I/O. Step-by-step implementations take you through the creation of Java solutions for client/server and Internet environments, using the latest releases of each API. Advanced Java Networking, Second Edition gives you the newest techniques to use with:

  • Servlets for dynamic Web content

  • JavaBeans to create plug-and-play software components

  • JMAPI for centralized management of Java objects

  • If you are a manager considering networked Java applications, you will find everything you need to understand the scope and possibilities of the project. If you are a professional Java software developer or engineer, you can't afford to miss the essential resources in Advanced Java Networking, Second Edition.

    About the CD-ROM

    Free CD is packed with live sample code to get you up to speed fast.

    Table of Contents

    1. Copyright
      1. Dedication
    2. Introduction
      1. What This Book Is All About
      2. Who Should Read This Book
      3. How to Read This Book
      4. Conventions
      5. Fixes and Updates
      6. Thanks a Million!
    3. 1. Advanced Java
      1. Basic Java
        1. Object-Oriented Design Using Java
          1. Classes vs. Interfaces
          2. Data Members
          3. Methods
          4. Constructors
          5. Creating and Initializing an Object
        2. Applying Good Object-Oriented Design Skills
          1. Inheritance
          2. Code Reuse
        3. OOP—Strong, Efficient, and Effective
      2. Java I/O Routines
        1. Streams
        2. The Java Core System
          1. The System Class
          2. Input Using the System Class
          3. Output Using the System Class
        3. Files
          1. The Basics
          2. Taking Files One Step Further
        4. The Abstract Window Toolkit and Swing Classes
          1. Input Alternatives
          2. Output Alternatives
        5. I/O in Short
      3. Introduction to Threading in Java
        1. What Are Threads?
          1. Threads in Your Computer
          2. Handling Conflicts
        2. Threading in Java
          1. The Thread Class
          2. Using the Entire Class As a Thread
          3. Inheriting from the Thread Class
          4. Thread Controls
          5. Synchronized Methods
          6. yield( ), wait( ), and notify( )
          7. Thread Priorities
          8. Daemon Threads
        3. Thread Summary
      4. Object Serialization
        1. What Is Serialization?
        2. Handling Object Relationships
        3. The Output Streams
        4. Handling Object Webs
        5. Reading Objects
        6. Security and Fingerprinting
        7. Serialization Overview
      5. Performance
        1. Performance Issues
          1. Download Performance
          2. Runtime Performance
        2. Summary of Performance Issues
      6. A First Look at Java Networking in Action
        1. Pulling It All Together
          1. Road Map for Success
          2. Project Planning
          3. User Interface
          4. Network Modules
          5. Servers
      7. Summary
    4. 2. TCP/IP Fundamentals
      1. In the Beginning…
        1. The Protocol Stack
        2. The OSI Stack
        3. The TCP/IP Stack
          1. Datagrams
      2. IP Addresses
      3. Protocols
        1. DNS
        2. HTTP
        3. CORBA and IIOP
        4. RMI
        5. JINI
      4. Summary
    5. 3. Java Sockets and URLs
      1. Sockets and Interprocess Communication
        1. Introduction to IPC
          1. Sockets
          2. What Are Sockets?
          3. Exploring Some of the Standard Protocols
          4. Daytime
          5. Echo
          6. Moving EchoTest to Sockets
        2. URL and URL Connection
        3. Summary of Sockets
      2. Client/Server Methodology
      3. The Pizza Order Protocol (TPOP)
      4. The TPOP Server
        1. Server Methodology
        2. Setting Up the Server
        3. Initializing the Server Socket
        4. Creating the Thread
        5. Detecting Information and Starting the Thread
        6. Gathering Information
      5. The TPOP Client
        1. Developing Clients for Servers
        2. Clients and Servers in Short
      6. UDP Client
        1. Datagrams
        2. Creating a UDP Sender
          1. Formatting a UDP Packet
          2. Sending the Packet to the Server
          3. Creating a UDP Receiver
      7. Featured Application
        1. Messaging Format
        2. Client
        3. Server
      8. Summary
    6. 4. Java Database Connectivity
      1. Inside JDBC
        1. Database Drivers
          1. Type 1 Drivers.
          2. Type 2 Drivers.
          3. Type 3 Drivers.
          4. Type 4 Drivers.
          5. The DriverManager Object.
          6. Database Connection Interface.
          7. Database Statement Object.
          8. ResultSet Access Control.
          9. JDBC and ODBC.
        2. JDBC in General
      2. Databases and SQL
        1. Creating an Access Database
        2. Simple SQL
          1. Generating SQL.
          2. Introduction to the ODBC Driver.
        3. Summary
      3. Retrieving Information
        1. Creating the User Interface
        2. Database Security
        3. Using the JDBC Driver
        4. Creating Queries
        5. Database and SQL Overview
      4. Storing Information
        1. Creating the Connection
        2. Forming a Statement
      5. A JDBC Version of the Featured App
        1. Creating the Database
        2. Mapping the Network Module to Database Queries
        3. Developing the Client
        4. Establishing the Connection
        5. Making an SQL Invocation
        6. Invoking SQL to Make a Change
        7. Shutting Down the Connection
      6. Summary
    7. 5. Java RMI: Remote Method Invocation
      1. Distributed Objects
        1. What Is RMI?
        2. How Does RMI Work?
          1. Stub/Skeleton Layer
          2. Remote Reference Layer
          3. Transport Layer
        3. Local vs. Remote Objects
          1. Garbage Collection
          2. Security
        4. Applet vs. Application
        5. Dynamic Method Invocations
        6. Overview of RMI
      2. Client
        1. RMI Client Methodology
          1. RMI Remote Classes
          2. RMI's Naming System
          3. Remote Invocations
        2. Catching Exceptions
        3. Handling Security Constraints
        4. Client Overview
      3. Server
        1. RMI Server Classes
        2. Creating a Server Interface
        3. Implementing a Server
        4. RMI Registry Classes
        5. RMI Server Security Constraints
        6. Generating Stubs and Skeletons
        7. Server Overview
      4. Callbacks
        1. Why Callbacks?
        2. Creating the Callback
        3. Implementing the Callback Client
        4. Filling in the Callback Method
        5. Registering Callbacks
        6. Invoking Callbacks
        7. Callbacks in Short
      5. A Java RMI Version of the Featured App
        1. RMI Interface
        2. RMI Client
        3. RMI Server
      6. New in JDK 1.2
        1. Activatable Objects
        2. Custom Socket Factories
      7. Summary
    8. 6. Java IDL: Interface Definition Language
      1. CORBA
        1. CORBA-Style Communication
        2. The CORBA Vision
        3. Communication with CORBA
        4. Separation of Interface and Implementation
        5. Different Vendors, Different ORBs
        6. Advantages of CORBA
        7. Common Object Services
        8. Object Administration
        9. Clients and Servers and Networks, Oh My!
        10. What CORBA Means for You
      2. The Interface Definition Language
        1. Interfaces
        2. Modules
        3. Interface Inheritance
        4. Variables and Structures
        5. Methods
        6. Constructed Data Types
        7. Exceptions
        8. Overview of the IDL
      3. Language Mappings
        1. What Exactly Are Language Mappings?
        2. The Sun Microsystems Java Language Mapping
        3. Interfaces, Modules, and Methods
        4. Interface Inheritance
        5. Variables and Structures
        6. Constructed Data Types
        7. Exceptions
        8. Java and CORBA Together
      4. CORBA Clients
        1. Designing a User Interface
        2. Defining the Problem
        3. The Cooler Interface Definition
        4. The Cooler User Interface
        5. Initializing the Client ORB
          1. Invoking a Remote Object
          2. Tracking Errors
          3. Implementing the Monitor
          4. Shutting Down Your Connection
        6. Client Overview
      5. CORBA Servers
        1. Defining an Interface and Generating Code
          1. Creating the Server Implementation
          2. Creating the Server Executable
          3. Registering with the ORB
        2. Server Overview
      6. CORBA Callbacks
        1. Java Callbacks
        2. Creating a Callback
        3. Registering a Callback
        4. Receiving and Handling a Callback
          1. Callbacks in Short
      7. A Java IDL Version of the Featured App
        1. Server Interface
        2. NetworkModule
        3. Calendar Server
      8. Summary
    9. 7. Web Servers, Server-Side Java, and More
      1. Inside an HTTP Server
        1. Web Server Architecture
        2. The HTTP Protocol
        3. Using a Web Server
        4. Advanced Web Server Features
        5. HTTP Server Overview
      2. Common Gateway Interface and CGI Scripts
      3. Servlets
        1. What Is a Servlet?
          1. The Servlet API
          2. Why Not CGI Scripts?
        2. Servlets Overview
      4. Dynamic Documents
        1. Creating the Servlet
          1. Handling Java Web Server Requests
          2. Setting Headers and Defining Content
          3. Creating the Document
          4. Now a Few Words on Servlet Testing and Deployment
          5. Servlets and HTML Forms Processing
          6. Form Tag.
          7. Input Tag
            1. As a Text Input or Password Field
            2. As a Check Box
            3. As a Radio Button
            4. As a Submit Button
            5. As a Reset Button
            6. As a Hidden Field
            7. As a File Name Field
          8. Select Tag
          9. Textarea Tag
          10. Reading the Form Screen
      5. A Servlet Version of the Featured App
        1. doGet( )
        2. getAppointments( )
        3. newAppointmentForm( )
        4. insertNewAppointment( )
      6. Java Server Pages
        1. Microsoft Active Server Pages (ASP)
        2. PHP
        3. Allaire Cold Fusion
        4. On to JSP
          1. JSP Directives
          2. JSP Tags
        5. Scriptlets and Expression Evaluation
        6. The Featured Application as a JSP
          1. The Calendara.jsp
          2. The AddAppointment.jsp
        7. Dynamic Documents Overview
      7. Multipurpose Servers
      8. Summary
    10. 8. Java Beans
      1. Component Models
        1. The Competition
      2. Overview of the Java Beans Component Model
        1. Interface Publishing
        2. Event Handling
        3. Persistence
        4. Layout
        5. Builder Support
        6. Distributed Beans
        7. Why Use Beans?
      3. Java Beans
        1. Component Interaction
        2. Network Communication
        3. User Interface Issues
        4. Persistence
        5. Events
        6. Properties
        7. Beans in a Nutshell
      4. Making a Bean
      5. Using Java Beans
        1. Creating a Java Beans Application
        2. A Simple Example
        3. Instantiating Components
        4. Connecting Beans Events
        5. Bean Introspection
      6. Server-Side Java Beans
      7. Enterprise Java Beans
        1. EJB Goal
        2. EJB Services
        3. Session and Entity Beans
        4. The EJB Container
        5. Summary
      8. COM/DCOM and ActiveX
        1. What Is ActiveX?
        2. ActiveX Controls
        3. ActiveX and Java
        4. Java Native Interface (JNI)
        5. Summary
      9. Summary
    11. 9. Application Servers
      1. High-Performance Web Servers
      2. Integrated Development Environment
      3. Interfacing to Enterprise Resource Planning Systems
      4. Ability to Interface with Transaction Processing Monitors
      5. Support Stateful Applications
      6. Connection Pooling of Database Connections
      7. Access to Legacy Applications and Legacy Databases
      8. Scalability Through Load Balancing
      9. Automatic Fail-Over
      10. Support of the Enterprise Java Beans Specification
      11. Summary
    12. 10. Jini: Sun's Technology of Impromptu Networks
      1. Examples of Jini
      2. Where Did Jini Come From?
      3. Our Working Jini Example
      4. Basic Jini Concepts: "Discovery, Join, and Lookup Oh My!"
        1. Server
        2. Client
      5. Getting Started with Jini
      6. Let's Get to the Code!
        1. Implementing the Jini Server
          1. A Walk Through the PrintService Code
        2. Implementing the Jini Client
          1. A Walk Through the PrintClient Code
        3. Running the Jini Server
        4. Running the Jini Client
        5. Good References to Get You Started
      7. Summary
    13. 11. JMX/JMAPI: Java Management API
      1. What Is Network Management?
        1. Network Management at a Glance
        2. Simple Network Management Protocol
        3. The Unique Management Problems of Java
        4. Network Administration Overview
      2. Modifying Clients for JMAPI
        1. AVM Base Classes
        2. AVM Help Classes
        3. Managed Object Interfaces
        4. Setting Up Notifications
      3. Modifying Servers for JMAPI
        1. The Admin Runtime Module
        2. ManagedObject Classes
        3. Implementing the ManagedObject
        4. Managed Attributes
        5. ManagedObjectFactory Classes
        6. Notifications
        7. Managed Data
        8. Server Agents
      4. Summary
    14. 12. What Are Directory Services?
      1. Some Background
      2. Introducing Java Naming Directory Interface
      3. Using the JNDI to Access LDAP-Based Data
        1. Setting up the Airius Directory
        2. The Airius Schema
        3. Connecting
        4. Searching
        5. Adding Persons to the Directory
        6. Modifying Information Already in the Directory
        7. Removing Entries from the Directory
        8. Authentication
      4. Summary
    15. 13. Java and Security
      1. Safety in Java
      2. The Java Security Model
        1. Easy to Use Fine-Grained Access Control
        2. Easy to Configure Security Policy
        3. Easy to Extend Access Control Structure
        4. Easy to Extend Security Checks to Applications
      3. Java Class Security
        1. The Bytecode Verifier
        2. The Class Loader
        3. The Security Manager
          1. Java 1.2 Security Policies
            1. Policy Files
          2. Security Tools
        4. Security Problems and Java Security Testing
      4. Encryption
        1. Java Cryptography Extension (JCE)
      5. Authentication
        1. Kerberos
        2. Digital Signatures and Public Key Encryption
      6. Secure Sockets Layer
      7. The Government and Security
        1. Export Control
        2. The "Clipper" Controversy
      8. Summary
    16. 14. Making an Architectural Decision
      1. Java Sockets
        1. Flexibility
        2. Simplicity
      2. Java RMI Decisions
        1. RMI Advantages
        2. RMI Disadvantages
        3. Three-Tier Applications in RMI
          1. Java RMI Is Not Robust
      3. Java IDL
        1. Advantages of Java IDL
        2. Disadvantages of Java IDL
        3. Java IDL Implementations
        4. Java IDL Is Robust
        5. Java IDL Is Difficult
        6. Java IDL Is Powerful
      4. JDBC
        1. Why JDBC Is Not Enough
        2. JDBC and Java IDL or Java RMI
        3. JDBC Alone
        4. JDBC Overview
      5. Other Java Technologies
        1. When to Use Beans
        2. When to Use Servlets and Java Server Pages
      6. Application Servers
      7. Summary
    17. Glossary