You are previewing Special Edition Using Java™ 2 Enterprise Edition.
O'Reilly logo
Special Edition Using Java™ 2 Enterprise Edition

Book Description

Java 2 Enterprise Edition is a combination of Java-related technologies including Java Server Pages, Servlets, and Enterprise Java Beans. Working together these “pieces” make Java a viable solution for enterprise-scale applications. "SE Using J2EE" starts with a section covering the core J2EE components and how they fit into the overall application architecture. The book then builds off this foundation to explore the practical applications of J2EE including incorporating XML into J2EE, creating wireless Web applications, network programming with J2EE, managing security and encryption, object programming with Serialization and Reflection, and programming Java applets in the enterprise. Later chapters discuss alternative approaches to solving problems in J2EE applications including debugging, decompiling and disassembly. The book finishes with a useful reference section discussing each of the core J2EE APIs.

Table of Contents

  1. Copyright
  2. About the Author
  3. Acknowledgments
  4. Tell Us What You Think!
  5. INTRODUCTION
  6. Enterprise Javabeans
    1. Application Architecture Concepts
      1. The Three Layers of an Application
      2. Single-Tiered Applications
      3. Two-Tiered Applications
      4. Three-Tiered Applications
      5. The Trade-Offs
      6. The "ilities"
      7. Hybrid Architectures
      8. Case Study: An Online Ordering System
    2. A Quick Primer on SQL
      1. Introduction to Relational Databases
      2. Relationships
      3. The Structured Query Language (SQL)
      4. Auto-Generated Keys
      5. Troubleshooting
    3. JDBC—The Java Database API
      1. What Is JDBC?
      2. JDBC Core Components
      3. A Simple Database Query Program
      4. Inserting, Updating, and Deleting Data
      5. Updating Data from a Result Set
      6. The JDBC Optional Package
      7. Troubleshooting
    4. Remote Method Invocation
      1. What Is RMI?
      2. Creating an RMI Server Object
      3. Creating an RMI Client
      4. Remote Method Parameters
      5. Using the RMI Registry
      6. Implementing a Remote Object Factory
      7. Performing Callbacks
      8. Remote Activation
      9. Troubleshooting
    5. Overview of Enterprise JavaBeans
      1. The Need for EJB
      2. Containers, Components, and Connectors
      3. Enterprise JavaBeans
      4. Session Beans
      5. Entity Beans
      6. Transactions
      7. Core Technologies
      8. Case Study
    6. Creating a Session Bean
      1. What Does a Session Bean Do?
      2. A "Hello World" Session Bean
      3. Creating a Stateless Session Bean
      4. More Details About Session Beans
      5. Creating a Session Bean That Does Some Work
      6. Troubleshooting
    7. Creating an Entity Bean
      1. What Is an Entity Bean?
      2. How an Entity Bean Interacts with the Database
      3. Creating an Entity Bean with Bean-Managed Persistence
      4. More Details About Entity Beans
      5. Using an Entity Bean from a Session Bean
      6. Passing References from One Entity Bean to Another
      7. Troubleshooting
    8. Using Container-Managed Persistence
      1. Why Use Container-Managed Persistence (CMP)?
      2. Creating a CMP Entity Bean Under EJB 1.1
      3. Creating a CMP Entity Bean Under EJB 2.0
      4. Troubleshooting
    9. EJB Transactions
      1. Why Transactions Are Important
      2. The ACID Test
      3. Who Starts and Ends a Transaction?
      4. Using Container-Managed Transactions
      5. Using the SessionSynchronization Interface
      6. Using the Java Transaction API (JTA) for Bean-Managed Transactions
      7. Troubleshooting
    10. Mapping Objects to a Relational Database
      1. Relational Models Versus Object Models
      2. Performance Issues
      3. Using an Object Database
      4. Using the TopLink Object-to-Relational Mapper
      5. Troubleshooting
    11. Debugging an EJB
      1. Why Debugging Is Tough
      2. Using Log Files to Debug an Application
      3. Using a Debugger
      4. Debugging an Enterprise JavaBean
      5. Troubleshooting
    12. EJB Design
      1. Client Access to Enterprise JavaBeans
      2. Session Beans Versus Entity Beans
      3. Creating View Objects
      4. Improving EJB Performance
      5. Case Study
  7. Java Server Pages and Servlets
    1. Servlets
      1. What Is a Servlet?
      2. A "Hello World" Servlet
      3. The Anatomy of a Servlet
      4. The HttpServlet Class
      5. Troubleshooting
    2. Java Server Pages
      1. A "Hello World" Java Server Page
      2. Using the <% %> Tags in a Java Server Page
      3. Displaying a Value with <%= %>
      4. Inserting Comments
      5. Declaring Methods and Variables with <%! %>
      6. Handling Multiple Threads in a JSP
      7. Choosing Between Servlets and Java Server Pages
      8. Troubleshooting
    3. Common JSP Tasks
      1. A Simple HTML Form
      2. Using the request Object
      3. Retrieving Form Variables in a Servlet
      4. Storing Data in a session Object
      5. How Sessions Work
      6. Forcing a New Session
      7. Handling Session Termination
      8. Handling Sessions Without Cookies
      9. Storing Application-Wide Data
      10. Troubleshooting
    4. Extending JSP with New Tags
      1. Including Other Files
      2. Forwarding to Another Page
      3. The <jsp:useBean> Tag
      4. Custom Tag Extensions
      5. A "Hello World" Tag
      6. Packaging and Installing a Tag
      7. Conditional Includes Using Custom Tags
      8. Accessing Tag Attributes
      9. Processing Body Content with a Custom Tag
      10. Adding Scripting Variables
      11. Troubleshooting
  8. Additional J2EE Technologies
    1. CORBA
      1. What Is CORBA?
      2. The Interface Definition Language (IDL)
      3. Creating a CORBA Server
      4. Creating a CORBA Client
      5. Attributes
      6. More About IDL
      7. Factories
      8. Callbacks
      9. Object References
      10. Dynamic Invocation
      11. Using CORBA and RMI Together
      12. CORBA Application Architecture
      13. Additional CORBA Services
      14. Troubleshooting
    2. JNDI—Java Naming and Directory Interface
      1. A Centralized Directory
      2. JNDI Basics
      3. Directory Operations
      4. Using LDAP with JNDI
      5. LDAP Classes and Attributes
      6. Troubleshooting
    3. JMS—The Java Message Service
      1. The Importance of Messaging
      2. Types of Messaging
      3. The Java Message Service (JMS)
      4. More About Messages
      5. Message-Driven Beans
      6. Troubleshooting
    4. Connecting to Existing Systems
      1. Types of External System Connections
      2. Socket Connections to Existing Systems
      3. Sending Messages to Existing Systems
      4. Using Custom Access Libraries
      5. Using the J2EE Connector API
      6. Case Study
    5. Packaging and Installing a J2EE Application
      1. Using an Automated EJB Packaging Tool
      2. How Enterprise JavaBeans Are Packaged
      3. EJB Deployment Descriptor Options
      4. Packaging Java Server Pages and Servlets
      5. WAR Configuration Options
      6. Application Deployment
      7. EAR Descriptor Options
      8. Troubleshooting
  9. Using XML with J2EE
    1. XML—The Extensible Markup Language
      1. What XML Is and Isn't
      2. Why XML Is Important in J2EE
      3. Basic XML Syntax
      4. Creating a Document Type Definition (DTD)
      5. Other XML Specifications
      6. Java Meets XML
      7. Creating XML Documents with Java
      8. Parsing an XML Document with Java
      9. Troubleshooting
    2. Using XSL to Translate XML Documents
      1. What Is XSL?
      2. A Simple XSL Style Sheet
      3. Using a Standalone XSL Processor
      4. Applying XSL Templates on the Browser
      5. Applying XSL Templates from a Servlet
      6. Navigating an XML Document with XPath
      7. JSP or Style Sheets?
      8. Troubleshooting
    3. Using Java-XML Tools
      1. The Need For Additional Tools
      2. The Example XML and Java Bean Files
      3. Using KBML to Serialize and Deserialize Java Beans
      4. Using JOX to Read and Write Objects in XML
      5. Using Quick to Read and Write Objects in XML
      6. Troubleshooting
    4. Remote Method Calls with XML-SOAP
      1. What Is SOAP?
      2. Using SOAP with Java
      3. Using SOAP with Enterprise JavaBeans
      4. Sending SOAP Requests via Email
      5. Troubleshooting
  10. Networking
    1. Networks and Network Protocols
      1. The Importance of Understanding the Network
      2. The Internet Protocol
      3. Domain Name Service (DNS)
      4. Firewalls
    2. Network Programming
      1. Socket Programming
      2. Using Datagram Sockets
      3. Choosing Between TCP and UDP
      4. Troubleshooting
    3. Overview of Internet Protocols
      1. Who Defines Internet Protocols
      2. Where to Find Internet Standards
      3. Basic Features of Internet Protocols
      4. Some Common Internet Protocols
      5. An In-Depth Look at the File Transfer Protocol
      6. Case Study
    4. The HTTP Protocol
      1. The HTTP Protocol
      2. Common Request Headers
      3. Common Response Headers
      4. The HTTP POST Command
      5. GET Versus POST
      6. HTTPS—Secure HTTP
      7. Case Study
    5. SMTP, POP3, and IMAP4—The E-mail Protocols
      1. The Simple Mail Transport Protocol
      2. The Post Office Protocol, Version 3
      3. The Internet Message Access Protocol 4
      4. The Java Mail API
      5. Troubleshooting
    6. Proxies and Relays
      1. Connections Are Everywhere
      2. Relaying Datagrams
      3. Creating a Custom Socket
      4. Case Study
  11. Security
    1. Introduction to Encryption Techniques
      1. What Is Encryption?
      2. Encryption Terminology
      3. Choosing the Right Kind of Encryption
      4. Guarding Against Malicious Attacks
      5. Digital Signatures
      6. Digital Certificates
      7. Case Study
    2. Encrypting Data
      1. The Java Cryptography Extension
      2. Generating an Encryption Key
      3. Encrypting Data
      4. Decrypting Data
      5. Encrypting Objects
      6. A Quick and Dirty Public Key Implementation
      7. Accessing the Keystore
      8. Exchanging Keys
      9. Troubleshooting
    3. Digitally Signing Data
      1. How Digital Signatures Work
      2. A Simple Digital Signature Algorithm
      3. Digitally Signing Data
      4. Troubleshooting
    4. Using the Secure Socket Layer (SSL)
      1. How the Secure Socket Layer works
      2. Managing Keys and Certificates
      3. Creating an SSL Server Program
      4. Creating an SSL Client Program
      5. Communicating with a Web Browser
      6. An SSL Relay Program
      7. Accessing Web Servers with SSL
      8. Using SSL with RMI
      9. Troubleshooting
    5. Java Security Features
      1. The Advantages of Built-In Security
      2. The Java Security Framework
      3. Signing a JAR File
      4. Troubleshooting
    6. J2EE Security
      1. Role-Based Security
      2. Basic Authentication
      3. Creating a Custom Login Form
      4. Checking Security Roles Programmatically
      5. Using Client Certificates for Authentication
      6. Troubleshooting
  12. Dynamic Java
    1. Serialization
      1. The Many Uses of Serialization
      2. Customizing Serialization
      3. Dealing with Multiple Versions
      4. Troubleshooting
    2. Reflection
      1. What Is Reflection?
      2. Examining Objects at Runtime
      3. Suppressing Access Restrictions
      4. Creating Dynamic Proxies
      5. Improving Reflection Performance
      6. Troubleshooting
    3. Dynamic Class Loading
      1. Loading Classes at Runtime
      2. Designing Servers to Use Dynamic Class Loading
      3. Troubleshooting
    4. Introspection
      1. How Introspection Works
      2. Using Introspection in an Application
      3. Choosing Between Introspection and Reflection
      4. Troubleshooting
    5. The Model-View-Controller Paradigm
      1. What Is Model-View-Controller?
      2. Using Reflection to Implement MVC
      3. Using MVC in a Web Application
      4. Calling Multiple Controllers and Views
      5. Case Study
    6. Code Generation
      1. Generating Code Automatically
      2. Using XML to Describe Objects
      3. Dealing with Changes
      4. To Generate or Not to Generate
      5. Case Study
  13. Applets
    1. Applet Development
      1. Why and When to Use Applets
      2. Creating an Applet
      3. Applet Security Restrictions
      4. Accessing Files and Data from an Applet
      5. Improving Applet Downloads
      6. Running Applets in a Standalone Application
      7. Using the Java Plug-In
      8. Troubleshooting
    2. Code Signing
      1. Why You Should Digitally Sign Code
      2. Signing Code for the Java Plug-In
      3. Signing Code for Internet Explorer
      4. Signing Code for Netscape Navigator
      5. Troubleshooting
    3. Using Enterprise JavaBeans from an Applet
      1. When Applets Make Sense in an EJB Application
      2. Creating an Applet That Accesses an EJB
      3. Getting to the Classes You Need
      4. Troubleshooting
    4. Web Start—An Alternative to Applets
      1. What Is Web Start?
      2. Creating a Web Start Application
      3. File Access and Other Useful Features
      4. Troubleshooting
  14. Problem Solving
    1. Narrowing Down the Problem
      1. The Art of Debugging
      2. Debugging Techniques
      3. Narrowing Down the Problem
      4. Troubleshooting
    2. Decompiling and Patching
      1. Decompiling a Java Class
      2. Disassembling a Java Class
      3. Patching a Java Library
      4. Troubleshooting
  15. J2EE in Practice
    1. A J2EE Web Application
      1. Designing a Web-Based EJB Application
      2. Creating the Entity Beans
      3. Creating the Session Bean
      4. Creating the Web Interface
      5. Deploying the Application
      6. Troubleshooting
    2. Using XML for Data Exchange
      1. Why XML Is Good for Data Exchange
      2. Parsing XML with SAX and DOM
      3. Troubleshooting
    3. Internationalization
      1. Detecting the Browser's Preferred Locale
      2. Using Locale-Based Text Formatters
      3. Using Resource Bundles
      4. Troubleshooting
    4. Creating a Wireless Web Application
      1. A Wireless "Hello World" Page
      2. A Brief Introduction to WML
      3. Detecting Wireless Clients in a JSP or Servlet
      4. A Wireless Score Entry and Reporting System
      5. Troubleshooting
    5. Creating a Business-to-Business Application
      1. What Does Business-to-Business Mean?
      2. Using Different Methods of Communication
      3. Data Formatting Issues
      4. Creating a B2B Application
  16. Appendixes
    1. JDBC API Reference
      1. The java.sql Package
      2. Interfaces
      3. Classes
    2. RMI API Reference
      1. The java.rmi Package
      2. Interfaces
      3. Classes
      4. RMISecurityManager
      5. The java.rmi.server Package
      6. Interfaces
      7. Classes
      8. The javax.rmi Package
      9. Classes
    3. CORBA API Reference
      1. The org.omg.CORBA Package
      2. Interfaces
      3. Classes
    4. JSP Syntax and API Reference
      1. JSP Syntax
      2. XML Syntax
      3. Java Server Pages API
      4. javax.servlet.jsp
      5. javax.servlet.jsp.tagext
    5. Servlet API Reference
      1. The javax.servlet API
      2. The javax.servlet.http API
    6. JNDI API Reference
      1. The javax.naming Package
      2. Interfaces
      3. Classes
      4. The javax.naming.directory Package
      5. Interfaces
      6. Classes
    7. JMS API Reference
      1. The javax.jms Package
      2. Interfaces
      3. Classes
    8. Java XML API Reference
      1. The javax.xml.parsers Package
      2. Classes
      3. The org.w3c.dom Package
      4. Interfaces
      5. The org.xml.sax Package
      6. Interfaces
      7. Classes
  17. Index