The J2EE APIs
Even though J2EE defines many technologies, we'll concentrate on the following:
Servlets: Servlets are server-side Java programs that process incoming HTTP requests from clients. Servlets are supported through servlets engines; popular examples include Tomcat from Apache, JRun from Allaire, and ServletExec from New Atlanta.
Java Server Pages (JSPs): JSPs can contain HTML and Java code, providing a mechanism for displaying results that will be returned to a user. JSPs are an extension of the servlet model: The first time a JSP is requested, the servlet engine compiles it into a servlet. The servlet engine then invokes the servlet and returns the value to the client.
Enterprise Java Beans (EJBs): EJBs represent a component model for capturing business logic, and can fall into one of four categories:
Stateless session beans: A stateless session bean is an abstraction representing the session of a user with a server. A stateless session bean stores the state of the session, but only for the current method invocation.
Stateful session beans: A stateful session bean is similar to a stateless session bean except that it stores the state of the request between method invocations. The prototypical example of a stateful session bean is a shopping cart; the contents of the cart need to be remembered between method invocations. Generally speaking, stateless systems (that is, systems that make use of stateless session beans) are more scalable than stateful ones.
Entity beans: An entity bean is an object representation of persistent data, which can be stored in a number of mechanisms, but most often relational databases. While the lifespan of session beans (stateless and stateful) is for the lifespan of the client session(s), the lifespan of an entity bean is determined by the lifespan of the associated data. Working with entity beans requires dealing with issues such as container managed persistence (CMP) and bean managed persistence (BMP).
Message beans: Introduced in EJB 2.0 and used with the Java Message Service (JMS is covered later), a message bean is a consumer of asynchronous messages.
Remote Method Invocation (RMI): RMI is used for invoking methods in remote Java objects. Like many distributed computing technologies (such as CORBA), RMI uses proxies to accomplish this functionality.
Java Naming Directory Interface (JNDI): JNDI provides a unified interface to multiple naming and directory services, including Novell Directory Services, Lightweight Directory Access Protocol (LDAP), and others. Since JNDI uses RMI as its underlying technology, it can only be used to register, locate, and bind to Java objects.
Java Database Connector (JDBC): JDBC provides a unified interface for dealing with multiple data stores, with a primary focus on relational databases. Connecting to a database requires the installation of a database-specific JDBC-compliant database driver. By interfacing with a database through JDBC (rather than directly with the database), an application is loosely coupled with the database, thus allowing the underlying database to change with minimal impact to the application.
Java Message Service (JMS): This is described in more detail in the following section.
Java Connector Architecture (JCA): This is also described in the next section.
Figure 1 shows all the major parts of the J2EE architecture.
Figure 1 The J2EE Architecture (excerpted).