You are on page 1of 4

Java EE

Java began life as a programming language designed for building stand-alone applications and grew rapidly into
other spheres. A large part of Java’s popularity can be attributed to its usage in creating web applications.

A web application consists of static and dynamic (interactive) web pages. Static web pages contain various types
of markup languages (HTML, XHTML, and so on) and are used, in general, to provide information; dynamic
web pages, on the other hand, are capable of generating content with the aid of additional web components.

Thus, a web application is a collection of web pages and is capable of generating dynamic content in response to
requests. Unlike a web page used merely to provide information, a web application lets you perform some activity
and save the result. Developing a web application, however, is fundamentally different from building stand-alone
applications and requires you to understand the following three key elements:

 The Java EE platform: This is the set of API specifications that are the building blocks of the web
application.
 The web container: The web container implements the API specifications of the Java EE platform.
Specifically, the web container provides the services for managing and executing web components such
as servlets, JSPs, filters, listeners, and render responses to the client.
 Web components: These are hosted by the container. These web components, such as servlets, JSPs,
filters, and listeners.

The Java EE Platform

The Java EE platform is driven by the following two goals:


 Providing the API specifications that are the building blocks of the web application.
 Standardizing and reducing the complexity of enterprise application development. It does this by
providing an application model that defines an architecture for implementing services as multitiered
applications. Figure 1 summarizes the evolution of Java EE and, for the sake of brevity, shows only the
new specifications added with each release.

Figure 1: The evolution of Java EE

The Java EE platform is aimed at standardizing and reducing the complexity of enterprise application
development by providing an application model that defines an architecture for implementing services as

1
multitiered applications. In a multitiered application, the functionality of the application is separated into distinct
functional areas, called tiers. Figure 2 illustrates the typical multitiered architecture in a Java EE application
model.

Figure 2: Multitier architecture in Java

The Client Tier


The client tier is the top tier in a multitiered Java EE architecture; it consists of application clients that make
requests to the Java EE server, which is often located on a different machine. The server processes the requests
and returns a response to the client. An example of a client is a web browser or a stand-alone application.

The Web Tier


The web tier consists of components that handle the interaction between clients and the business tier. After
receiving a request from the client, the web tier does the following:
1. Collects input from the client
2. Controls the flow of screens or pages on the client
3. Maintains the state of data for a user’s session
4. Obtains results from the components in the business tier
5. Generates dynamic content in various formats to the client

As shown in Figure 1, a new Web Profile specification was first added in Java EE 7. As mentioned earlier, the
goal of Web Profile is to allow developers to create web applications with the appropriate set of technologies.

The multitier architecture of Java EE has a tremendous impact on the development of Java enterprise
applications. A Java enterprise application can be defined as a Java application that utilizes the enterprise services
offered by Java EE.

2
In fact, a web application can be classified as an enterprise application if it utilizes Java EE services in the form
of components packed in the web tier. Java EE isolates these services functionally into separate tiers, as illustrated
in Figure 2, by providing an application model on which the Java enterprise applications should be built.

An Enterprise Application
As a consequence, the Java enterprise application mirrors the multitier architecture of Java EE. Figure 3 illustrates
a generalized view of the layers of a typical web application.

Figure 3: A generalized view of layers in an enterprise application

Each layer in Figure 3 is an area of concern, for the application. For instance, the web layer deals only with
employing the web tier components of Java EE. Having different layers in an application results in what is called
a separation of concerns. In terms of implementation, this separation of concerns is achieved using coarse-
grained interfaces.

The concern is the feature, functionality or business functions with which the application’s developer needs to
be concerned. Crosscutting such concerns is inherent in complex systems and leads to code scattering, which is
when code for one concern spans many modules, and code tangling, which is when code in one module
concentrates on addressing multiple concerns. Code scattering and code tangling lead to a lack of clarity,
redundancy, rigidity, and continuous refactoring.

Separation of concerns, one of the main goals of software engineering, lets you handle each service on its own
and thereby does the following:
 Promotes traceability within and across the artifacts in the system, throughout the life cycle of the system
 Controls the impact caused by the change, thereby providing scope for evolution and noninvasive
adaptation
 Promotes development of cohesive units, thereby facilitating reuse

Web Layer
The web layer of a web application consists of the web tier components of Java EE such as servlets and JSP.
The web layer can access the service layer, but there should not be a tight coupling between the web layer and
the service layer. That is, changing the service layer should not impact the web layer.

3
Service Layer
The service layer consists of the business tier components of Java EE such as Enterprise JavaBeans (EJBs). The
service layer can access the data access layer, but there should be no tight coupling between the service layer and
the data access layer. In fact, the service layer should not know anything about the web or data access layer. The
service layer provides a coarse-grained interface for the web layer.

Data Access Layer


The data access layer consists of the data tier components of Java EE such as JDBC and JPA. This layer should
not contain any business logic. This layer abstracts the actual persistence mechanism (in other words, JDBC or
JPA) from the service layer by providing the coarse-grained interface to the service layer.

You might also like