Today, more and more developers want to write distributed
transactional applications for the enterprise and leverage
the speed, security, and reliability of server-side technology.
One approach is to use a multitiered model where a thin-client
application invokes business logic that executes on the server.
Normally, thin-client multitiered applications are hard to write
because they involve many lines of intricate code to handle
transaction and state management, multithreading, resource
pooling, and other complex low-level details.
The JavaTM 2 Platform, Enterprise
Edition (J2EETM),
architecture makes these applications easy to
write because the low-level details are separated from the
business logic. J2EE application developers concentrate on
creating the best business solution and leave the rest to the
underlying platform.
Developing J2EE Applications
J2EE application developers write application components.
An application component is a self-contained module that
is added to and interfaces with other application components.
Application components include thin-client applications, applets,
servlets, and JavaServer PagesTM;
and server-side Enterprise JavaBeansTM.
Application components are bundled into archive files such
as Java Archive (JAR) or Web Archive (WAR), assembled into
complete J2EE applications, and delivered as Enterprise Archive (EAR)
files.
An example J2EE application could have an HTML form to prompt the user
for data, a servlet to receive the data from the form and process it,
and an Enterprise Bean to store data in a database.
The HTML form and servlet are bundled in a WAR file, the Enterprise
Bean is bundled in a JAR file, and the WAR and JAR files are both
added to the EAR file, which is deployed to production.
The application programming model is very flexible. A WAR file can
be delivered with self-contained JavaServer Pages that implement an
application on their own, or an application composed of JavaServer
Pagess and enterprise Beans can be combined in an EAR.
Getting Started
To write J2EE application components, an application programmer
needs to obtain a J2EE product from a product provider. Product
providers are typically operating system, database system,
application server, or web server vendors who implement the
J2EE platform according to the
Java 2 Platform Enterprise
Edition Specification.
The product comes with the Java APIs for the Enterprise,
J2EE application server, HTTP, HTTP over secure socket layer (SSL)
also known as HTTPS,
a database, and deployment tools. In short, everything needed to write and
assemble application components, and to deploy complete J2EE applications.
You should also get the free downloads of the Java 2
Enterprise Edition, Software Developer Kit (J2EE SDK),
and Sun BluePrints(tm) Design Guidelines for the Java(tm) 2 Platform,
Enterprise Edition.
While you do your actual development on the J2EE product, you
use the J2EE SDK for rapid prototyping environment.
You use the Sun BluePrints(tm) Design Guidelines for the Java(tm) 2 Platform,
Enterprise Edition to guide you in making the
best design and implementation decisions.
The J2EE architecture also includes the Compatibility Test Suite.
The J2EE Compatibility Test Suite is used by providers to verify their
products and tools are compatible with the J2EE standard. This suite is not
available for the Beta release.
J2EE SDK
Sun Microsytems provides a free download of its
J2EE SDK.
The J2EE SDK is an operational definition of the J2EE platform
and specification. It is not a commercial product and its licensing agreement
prohibits commercial use. However, it is freely available for demonstrations,
prototyping, and education as follows:
-
Product providers use the J2EE SDK to determine what
their implementations must do under a given set of application conditions,
and to run the J2EE Compatibility Test Suite to test that their J2EE products
fully comply with the specification.
-
Developers run their J2EE applications on the J2EE SDK
to verify the applications are fully portable across all J2EE products and tools.
To support J2EE applications development, the J2EE SDK
includes Java WebServerTM, Cloudscape database,
J2EE server, Extensible Markup Language (XML) support, and the J2EE APIs.
J2EE APIs
Some of the J2EE APIs listed below are standard extensions to the
Java 2 Platform, Standard Edition. The Java 2 Platform, Standard Edition,
is required to run the J2EE SDK,
and provides core APIs for writing applets and applications, core
development tools, and the Java virtual machine1.
If you want to use Java 2 Platform, Standard Edition, applets, in your J2EE application,
download and install Java Plug-In. Java Plug-In lets you run Java 2 applets
in browsers that support an earlier release of the Java Runtime Environment
(JRE). The J2EE SDK also provides J2EE deployment
tool for deploying Enterprise Archive files, and development tools for
doing things like starting the application server, verifying archive files,
and creating database tables.
Servlets 2.2
javax.servlets
and
javax.servlets.http
Lets you extend a server program to enhance its
functionality. Servlets are commonly used to extend a
web server by providing dynamic content.
JavaServer PagesTM 1.1
javax.servlets.jsp
and
javax.servlets.jxp.tagext
Lets you put snippets of servlet code directly into a static
HTML page.
Enterprise JavaBeansTM 1.1
javax.ejb
and
javax.ejb.deployment
Lets you write a body of code with fields and methods to
implement modules of business logic.
JDBCTM 2.0
javax.sql
Provides uniform access to a wide range
of relational databases.
RMI-IIOP 1.0
javax.rmi
and
javax.rmi.CORBA
Lets RMI code look up an object using
CORBA services.
Java Message Service 1.0
javax.jms
Lets you write code to access enterprise messaging systems.
Java Naming and Directory Interface
(JNDITM) 1.2
javax.naming
, javax.naming.directory
,
javax.naming.event
, javax.naming.ldap,
and
javax.naming.spi
.
Provides a unified interface to multiple naming and
directory services in the enterprise so application components
can access naming and directory services.
Java Transaction API 1.0
javax.transaction
Provides a standard demarcation interface for demarcating
transactions. This API is
not available in the J2EE SDK, Beta release.
JavaMailTM 1.1
javax.mail
Provides a framework to build mail and messaging
services so application components can send email.
JavaBeans Activation Framework 1.0
javax.activation
This API is included because JavaMail uses it.
It provides standard services to determine the type of an
arbitrary piece of data, encapsulate access to it, discover
the operations available on it, and instantiate the appropriate
Bean to perform those operations.
Extensible Markup Language (XML)
The J2EE platform supports Extensible Markup Language (XML) so servlets and
JavaServer Pages executing in the web server can generate both HyperText Markup
Language (HTML) pages and XML format data. XML is a text-based markup language
for defining what information is as opposed to how it looks.
For example, in an XML document you can define the words Zelda Zee to
be a customer name and ZZ to be a customer ID. This way, the
information can be handled according to what it is. In HTML, you can
make Zelda Zee and ZZ appear in bold or italics, but you cannot
define them to be a customer name and customer ID.
Document Type Definition (DTD) is part of the XML specification. It
specifies the kinds of tags that can be included in an XML document,
and the valid arrangements of those tags. A DTD is used to validate
XML structures to make sure you create only valid XML structures and that XML
structures you send or receive are valid.
Programs to access XML documents use Simple API for XML (SAX) or
Document Object Model (DOM) APIs.
Application Programming Model
The application programming model is a standard programming model
for developing multitier, thin-client applications on the J2EE platform.
It consists of a body of technologies and principles to guide the
J2EE applications developer in doing such things as deciding on the most
appropriate implementation options, making the best use of JavaServer Pages
and servlets, choosing a good design when implementing
business logic, and effectively mapping the J2EE security model to enterprise
computing environments and infrastructures.
The application programming model is described in the
J2EE
Sun BluePrints(tm) Design Guidelines for the Java(tm) 2 Platform,
Enterprise Edition document. To put the model
into practice, the application programming model
document presents an example application
designed and implemented according to these guidelines. Of course the
example and explanatory text show one way to put the model into
practice and should be taken as illustrative only. As with any
model, the design guidelines should serve as a guide because there will
always be more than one right way to use them.
Monica Pawlan,
a staff writer for the Java Developer
ConnectionSM (JDC), is
author of Essentials of the Java Programming Language: A Hands-On
Guide (Addison-Wesley, 2000), and co-author of Advanced Programming
for the Java 2 Platform (Addison-Wesley, 2000).
Reader Feedback
Tell us what you think of this article.
1 As used on this web site, the terms Java virtual
machine or Java VM mean a virtual machine for the Java platform.