Introduction

The world has come a long way since Duke first started tumbling in early versions of Netscape Navigator. Java has outgrown its humble origins as a cool way of providing interactivity on Web pages and has found a new role as a major, server-side development platform. The actual Java language has changed little in the intervening years, but an enterprise-quality infrastructure has risen up around it. This infrastructure, Java 2 Enterprise Edition or J2EE for short, allows Java developers the ability to create sophisticated and powerful enterprise applications that provide mission-critical functionality for many thousands of users.

Unlike competing platforms, such as Microsoft .NET, J2EE is a specification rather than a product. The capabilities and functionality of each release of J2EE is agreed on through the Java Community Process (JCP). The platform is then implemented by application server vendors and producers, such as Sun Microsystems, BEA, IBM, ATG, Macromedia, JBOSS and OpenEJB. This means that J2EE developers have a choice of product vendors from whom to select, based on quality, support, or ease of use. The ability to submit technologies through the JCP, and the two-way flow that exists between the main Java vendors and the open-source community, ensures that a constant stream of new ideas helps move J2EE forward.

This book will take you on a journey through the J2EE landscape, from the simplest components through design considerations and on to the latest Web Services. There is a lot to learn in three weeks—but this book should provide the essential grounding you need to use the J2EE platform effectively. If you need to create robust enterprise applications and Java is your tool of choice, read on.

How This Book Is Organized

Sams Teach Yourself J2EE in 21 Days covers version 1.4 of the J2EE platform. It is organized as three separate weeks that guide you through the different functionality provided by J2EE.

The first week gives you a broad grounding in J2EE before moving on to investigate Enterprise JavaBeans (EJBs) in detail:

  • Day 1, “The Challenge of N-Tier Development,” defines the landscape in which J2EE applications operate and provides the architectural concepts with which you need to become familiar to create J2EE applications.

  • Day 2, “The J2EE Platform and Roles,” takes you on a whistle-stop tour of the J2EE platform, the major technologies, the types of components from which J2EE applications are assembled, and the container with which they interact. You also install the J2EE platform and start to look at the case study used throughout the book.

  • On Day 3, “Naming and Directory Services,” you start using your first J2EE API, the Java Naming and Directory Interface (JNDI), to store, retrieve, and manipulate information that can be accessed by all J2EE components.

  • Day 4, “Introduction to Enterprise JavaBeans,” introduces Enterprise JavaBeans (EJB)—the core technology of the J2EE platform. You will examine the role of EJBs and how they work. You will then deploy a sample EJB and create a simple client application for it.

  • On Day 5, “Session EJBs,” you will explore Session EJBs in more depth. This includes the creation of both stateful and stateless Session EJBs.

  • Day 6, “Entity EJBs,” moves on to Entity EJBs and examines their role and lifecycle. Particular attention is paid to how state is stored and retrieved using Bean-Managed Persistence (BMP).

  • On Day 7, “Container-Managed Persistence, Container-Managed Relationships, and EJB Query Language,” the discussion of Entity EJBs expands to cover entities that use Container-Managed Persistence (CMP) to store and retrieve their state. This includes an exploration of the EJB Query Language and Container-Managed Relationships (CMR).

The second week moves beyond EJBs to look at asynchronous interaction and the development of Web-based components:

  • On Day 8, “Transactions and Persistence,” you will delve deeper into the use of transactions in the J2EE platform—what they can achieve and how your components can take advantage of them. Some alternative persistence mechanisms are also explored.

  • Day 9, “Java Messaging Service,” looks at asynchronous messaging with the Java Message Service (JMS) using message queues and topics. You will apply JMS to implement a producer and consumer of asynchronous messages.

  • Day 10, “Message-Driven Beans,” builds on the coverage of JMS to associate message queues with Message-driven EJBs. You will create an EJB whose functionality is triggered on receipt of an asynchronous message.

  • On Day 11, “JavaMail,” another asynchronous communication mechanism is examined—namely email. You will learn how to send and retrieve email under J2EE and how this can be applied to transport data in a J2EE application.

  • Day 12, “Servlets,” is the first of three Web-oriented days that explore the creation of Web-oriented J2EE applications. This day starts by creating servlets to take advantage of the EJB-based services you built earlier. You will look at the servlet lifecycle and central issues, such as session tracking and state management.

  • Day 13, “JavaServer Pages,” looks at how JavaServer Pages (JSP) can help to integrate Java and J2EE functionality with HTML content. It examines the role of JSPs and how JavaBeans and the Expression Language (EL) can be used to encapsulate Java functionality in JSPs.

  • On Day 14, “JSP Tag Libraries,” you will explore the features of the JavaServer Pages Standard Tag Library (JSTL) and then develop custom JSP tag libraries to encapsulate Java functionality to improve the maintainability of the JSP pages.

The third week explores essential aspects of enterprise applications, such as security and integration, before moving on to application design and ending with a look at the Web Service functionality that will form the future of J2EE:

  • Day 15, “Security,” begins week 3 by applying security to your J2EE application. You will weigh the benefits of declarative and programmatic security and determine how they can be applied within your application.

  • On Day 16, “Integrating XML with J2EE,” you will examine the role of XML in J2EE applications. You will create J2EE components that produce and consume XML documents and process data using the Java APIs for XML Processing (JAXP).

  • Day 17, “Transforming XML Documents,” focuses on the transformation of XML documents into other formats, including other dialects of XML, primarily using the XSLT transformation language. Again, JAXP allows you to do this programmatically from within J2EE components.

  • On Day 18, “Patterns,” you will take some time to consider the bigger picture and examine design issues for J2EE applications. The specific focus will be on common patterns that have been found as people have applied J2EE technologies in live applications. You will use this knowledge to improve parts of the case study design.

  • Day 19, “Integrating with External Resources,” explores the various technologies that can be used to integrate J2EE applications with non-J2EE components and services. These mechanisms include the Java Connector Architecture, CORBA, RMI-IIOP, and the Java Native Interface.

  • Day 20, “Using RPC-Style Web Services with J2EE,” looks at how to expose J2EE components as Web Services. You will use the Java API for XML-based RPC (JAX-RPC) to create Web Services based on servlets and EJBs.

  • Day 21, “Message-Style Web Services and Web Service Registries,” concludes the tour of J2EE-based Web Services. You will create a message-oriented Web Service using the SOAP with Attachments API for Java (SAAJ) and the Java API for XML Messaging (JAXM). You will also examine the role of XML-based registries and how the Java API for XML Registries (JAXR) enables access to this information.

About This Book

This book is a practical, down-to-earth guide for intermediate Java developers. It is not intended to be a reference book, with lists of API calls or extensive discussion of the inner workings of the technologies. Rather, it provides you with a grounding in applying the essential J2EE technologies and leads you through the essential steps required to get a program or component written, packaged, and deployed on the J2EE platform. By the time you finish Sams Teach Yourself J2EE in 21 Days, you should have the confidence to create or maintain code that uses any of the major J2EE APIs.

What's New in This Edition?

This is the second edition of Teach Yourself J2EE in 21 Days. The first edition was targeted at J2EE 1.3 and this edition has been enhanced to include the new J2EE 1.4 features.

The main changes introduced for J2EE 1.4 are:

  • JSP 2.0 Expression Language (EL)— covered on Day 13

  • JavaServer Pages Standard Tag Library— covered on Day 14

  • Web Services— covered on Day 20 and Day 21

Smaller changes were made to incorporate the:

  • EJB Timer service— covered on Day 5

  • EJB QL enhancements— covered on Day 6

  • Enhanced JMS API— covered on Day 9 and Day 10

The code in this edition was developed and validated against the Sun Microsytems' J2EE 1.4 SDK (available from http://java.sun.com/j2ee/1.4/download-dr.html).

This edition also includes:

  • Full instructions for developing and deploying J2EE components using the J2EE SDK 1.4.

  • Revised and updated JavaMail examples— see Day 11.

  • Revised and updated Connector Architecture examples— see Day 19.

Who Should Read This Book?

This book is intended for experienced Java developers who have been involved with Java development for at least 3 to 6 months. You should be confident writing Java code and familiar with the commonly used Java 2 Standard Edition APIs, such as string handling, JDBC, collections, iterators, and so on.

In addition to a firm grasp of Java, the following knowledge will speed your progress through the book:

  • An understanding of how the Web operates, such as the use of a Web browser to retrieve pages of HTML from Web Servers.

  • Familiarity with XML syntax to the level of reading small extracts of XML containing elements, attributes, and namespaces.

  • An understanding of relational databases and how data is structured in tables. A familiarity with basic SQL to the level of understanding simple queries, inserts, updates, and joins.

  • Familiarity with distributed systems, such as n-tier development, client-server programming, and remote procedure calls.

If you are not familiar with one or more of these topics, don't panic! Appendix A provides introductory material on XML. The essential concepts of distributed systems and Web-based development are covered in the book as required.

How This Book Is Structured

This book is intended to be read and absorbed over the course of three weeks. During each week, you read seven chapters that present concepts related to J2EE and the creation of enterprise applications in Java. Care has been taken to try to ensure that concepts and technologies are introduced in an appropriate order, so it is best to read the chapters sequentially if possible.

At the end of each lesson are a set of questions about the subject covered that day. Answers to these questions are provided by the authors. There are also exercises for you to test your newly found skills by creating some related application or service.

The exercises in the book are largely based around a case study that is described in detail at the end of Day 2. The files for the case study and solutions to the exercises can be found on the Web site that accompanies this book. The idea of the case study is that it will help you apply J2EE technologies and techniques in a consistent context and as part of a working application. This should provide you with a deeper understanding of the technology involved and how to apply it than is possible working with standalone examples.

Typographic Conventions

NOTE

A Note presents interesting, sometimes technical, pieces of information related to the surrounding discussion.


TIP

A Tip offers advice or suggests an easier way of doing something.


CAUTION

A Caution advises you of potential problems and helps you avoid causing serious damage.


Text that you type, text that should appear on your screen, and the names of Java classes or methods are presented in monospace type.

Source code and updates to this book

All the code and examples in this book are available for download from our Web site, www.samspublishing.com, where we also will post updates and corrections as we learn of them.

At the Sams home page, type this book's ISBN number 0672325586 into the “search” window, press return, and you'll be taken to the book's page.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.72.165