Java EE Architecture and Components (Servlets, JSP, EJB, JPA)

Niranjan Girhe
5 min readMar 14, 2023

--

Java Enterprise Edition (Java EE) is a platform for building enterprise-level web applications. Java EE provides a set of specifications and APIs that make it easy to build scalable, reliable, and secure applications. Java EE is a component-based platform that uses a multitier architecture and provides containers for executing applications. In this article, we will discuss the architecture of Java EE and its components such as Servlets, JSPs, EJBs, and JPA.

Java EE Architecture

Java EE uses a multitier architecture that separates an application into tiers based on their functionality. The different tiers of Java EE architecture are:

  1. Client Tier: This tier represents the end-users who interact with the application. The client tier can be a web browser, a mobile device, or a standalone application.
  2. Web Tier: This tier is responsible for handling HTTP requests and generating responses. The web tier includes components such as Servlets, JSPs, and web frameworks.
  3. Business Tier: This tier contains the application’s business logic and performs the processing of business logic. The business tier includes components such as Enterprise JavaBeans (EJBs) and messaging.
  4. Persistence Tier: This tier manages the application’s data and provides access to the data store. The persistence tier includes components such as Java Persistence API (JPA) and Java Database Connectivity (JDBC).
Java EE Architecture

Java EE Components

Java EE provides a set of components and APIs that make it easy to build enterprise-level web applications. The different components of Java EE are:

1. Servlets

Servlets are server-side components that handle HTTP requests and generate responses. Servlets are part of the web tier and can be used to develop dynamic web pages. Servlets can interact with other components such as JSPs and EJBs to perform the application’s business logic.

Servlets are loaded and managed by the container, which provides services such as threading, security, and transaction management. Servlets are typically implemented using the javax.servlet package, which provides a set of classes and interfaces for developing Servlets.

Servlets

2. JavaServer Pages (JSPs)

JavaServer Pages (JSPs) are server-side components that are used to generate dynamic web pages. JSPs are part of the web tier and are often used in conjunction with Servlets to create dynamic web pages.

JSPs are compiled into Servlets by the container and can contain both static content and dynamic content. JSPs use tags to encapsulate Java code, HTML, and other content. JSPs can interact with other components such as Servlets and EJBs to perform the application’s business logic.

JavaServer Pages

3. Enterprise JavaBeans (EJBs)

Enterprise JavaBeans (EJBs) are server-side components that are used to perform the application’s business logic. EJBs are part of the business tier and are often used in conjunction with Servlets and JSPs.

EJBs are loaded and managed by the container, which provides services such as transaction management, security, and threading. EJBs are typically implemented using the javax.ejb package, which provides a set of classes and interfaces for developing EJBs.

There are three types of EJBs:

  • Session Beans: Session Beans are used to perform a specific task for the client.
  • Entity Beans: Entity Beans are used to represent persistent data and are stored in a database.
  • Message-Driven Beans: Message-Driven Beans are used to process messages asynchronously.

4. Java Persistence API (JPA)

Java Persistence API (JPA) is a specification that provides a set of interfaces and classes for managing the application’s data. JPA is part of the persistence tier and is used to interact with the database.

JPA provides an object-relational mapping (ORM) framework that maps Java objects to database tables. JPA provides a set of annotations that can be used to define the mapping between Java objects and database tables.

JPA provides a set of EntityManager classes that are used to interact with the database. The EntityManager class provides methods for querying, inserting, updating, and deleting data from the database. JPA also provides a set of query languages such as Java Persistence Query Language (JPQL) and Criteria API for querying the database.

Java Persistence API

Java EE containers

Java EE containers are responsible for managing the components and providing services such as threading, security, and transaction management. Java EE containers provide a runtime environment for the components and ensure that the components follow the Java EE specification.

There are two types of containers in Java EE:

1. Web container

The web container is responsible for managing Servlets and JSPs. The web container provides services such as threading, security, and transaction management. The web container provides a runtime environment for the Servlets and JSPs and ensures that they follow the Java EE specification.

2. EJB container

The EJB container is responsible for managing EJBs. The EJB container provides services such as transaction management, security, and threading. The EJB container provides a runtime environment for the EJBs and ensures that they follow the Java EE specification.

Java EE containers

Conclusion

Java EE is a platform for building enterprise-level web applications. Java EE provides a set of specifications and APIs that make it easy to build scalable, reliable, and secure applications. Java EE uses a multitier architecture and provides containers for executing applications. The different components of Java EE such as Servlets, JSPs, EJBs, and JPA provide a way to develop dynamic web pages and perform the application’s business logic. Java EE containers are responsible for managing the components and providing services such as threading, security, and transaction management. With the use of Java EE, developers can build robust and scalable enterprise applications.

--

--

Niranjan Girhe

A highly Motivated engineer and Android, Game development enthusiastic. I have a strong desire for learning new technologies and adopting them rapidly.