Java EE Introduction

Introduction

The J2EE platform uses a distributed, multi-tiered application model for enterprise applications.

Application logic is divided into components according to function, and the various application components that make up a J2EE application are installed on different machines depending on the tier in the multi-tiered J2EE environment to which the application component belongs.

Figure given below shows two multi-tiered J2EE applications divided into the tiers described in the following list. The J2EE application parts shown in figure given below are presented in J2EE components, which are listed as under:

  • Client-tier components run on the client machine.
  • Web-tier components run on the J2EE server.
  • Business-tier components run on the J2EE server.
  • Enterprise information system (EIS)-tier software runs on the EIS server.

Java Enterprise Edition is used to develop distributed application & web services. It is a component-based approach to develop web app. J2EE apps considered as 3 tiered apps since it is divided on 3 different machines/tiers

  • Client – (Presentation)
  • J2EE sever – (Application/Business)
  • Database – (Data Access)

1-tier Application, AKA  Standalone application

All the layers are in a single software package. for example : MP3 player, MS Office Data is stored in the local system

2 tier Application, AKA  Client-Server app

The Two-tier architecture is divided into two parts:

  1. Client app (Client tier)
  2. Database (Data tier)

For Example : Contact Management System created using MS- Access

3 tier Application, AKA  Web-Based app

The Three-tier architecture is divided into three parts

  1. Presentation layer   (Client Tier)
  2. Application layer   (Business Tier)
  3. Database layer   (Data Tier)

For Example: Any large scale web application or website (amazon, flipkart, google) on the internet

Logical Layers in multi-tier

Multi-tiered / web apps are divided in following 6 logical layers

(1) Presentation Layer:

  • It acts as Front End.
    • Responsible for user interface
    • It determine the how to display the information

(2) Presentation Logic:

  • It defines “What is to be displayed to user”.
    • It determines the screen structure.
    • It is application dependent.

(3) Application Logic:

  • It is the main layer of Application, its contains coding
  • It defines the functionality of Application.
  • It is application dependent

(4) Business Logic:

  • Business level rules of an organization, which is common for whole application.
  • It follows the policy and rules of business organization
  • It contains customize setting for application with respect to business organization
  • It is business organization dependent

(5) Database Logic:

  • It contain data dictionary
  • It describe the structure of database such as tables, columns, data type of columns, primary key, secondary key etc.,
  • It is application dependent

(6) Database Manager:

  • It is responsible for actual storage of data base
  • It can be application/organization dependent

Enterprise Architecture Types

  • Single Tier : All logical layers reside on single machine
    • It is not distributed application. It Cannot be scaled up to handle multiple users, and do not provide an easy means of sharing data across an enterprise.
    • Example : Application like word, excel, paint etc.,
  • Two Tier : All logical layers are divided in to two independent process     (client & sever)
    • Both process either reside on single or different machine.
    • Example: Application like VB as Front-End and ODBC as Back-End.
  • Three Tier : All logical layers are divided on three process
    • First Tier: Referred as the Presentation Layer. It consists of a GUI to interact with the user.
    • Middle Tier: Known as Business layer It consists of the application or the business logic, Represents the code that the user calls upon through the presentation layer to retrieve the data from the data layer.
    • Third Tier: called the Data Layer, it contains the data access logic needed for the application.

Web development usage of 3-tier

In the web development field, three-tier is often used to refer to websites, commonly electronic commerce websites, which are built using three tiers:

A front-end web server serving static content. In web-based application, front end is the content rendered by the browser. The content may be static or generated dynamically.

A middle dynamic content processing and generation level application server A back-end database or data store, comprising both data sets and the database management system software that manages and provides access to the data.

N-Tier Architecture

An N-Tier Application program is one that is distributed among three or more separate computers in a distributed network. The most common form of n-tier is the 3-tier Application, and it is classified into three categories.

  • User interface programming in the user’s computer
  • Business logic in a more centralized computer, and
  • Required data in a computer that manages a database.

This model provides Software Developers to create Reusable application/systems with maximum flexibility. In N-tier, “N” refers to a number of tiers or layers are being used like – 2-tier, 3-tier or 4-tier, etc. It is also called “Multi-Tier Architecture”.

The n-tier architecture is an industry-proven software architecture model.

It is suitable to support enterprise level client-server applications by providing solutions to scalability, security, fault tolerance, reusability, and maintainability.

It helps developers to create flexible and reusable applications.

N-Tier Architecture Types

In N-Tiers, 6 layers are divided in unknown number of tiers, It can be virtually distributed in following segments:

  1. User Interface (Presentation layer) : Interact with the DB & the user
  2. Presentation Logic
  3. Business Logic : Model the app’s business logic or rules, often through the interaction with the application data
  4. Infrastructure services : Provide additional functionality required by the app components such as messaging & transactional support
  5. Data Layer : Stores the data of the enterprise

J2EE Architecture

 JEE is a set of four independent tiers

  • Client Tier
  • Web Tier
  • Enterprise Java Beans Tier (Business)
  • Enterprise Information System Tier (EIS)

Client Tier

The clients make requests to the server. The server processes the requests & returns a response back to the client. Clients can be

  • a web browser,
  • a standalone app,
  • or other servers. Clients run on a different machine from the JEE server.

Web Tier

It handle the interaction between clients & business tier. Its primary tasks are :

  • Dynamically generate content in various formats for client.
  • Collect input from users of the client interface and return appropriate results from the components in the business tier.
  • Control the flow of screens or pages on the client.
  • Maintain the state of data for a user’s session.
  • Perform some basic logic and hold some data temporarily in Java Beans components.

Enterprise Java Beans Tier (Business Tier)

  • It contain EJB which mange the client request.
  • EJB is a sever-side component written in Java to manage the Application
  • EJB retrieves the request Data from EIS (Data Tier).
  • EJB also manage the concurrency, security, fault tolerance and Scalability.
  • EJB also contain the Business Logic which contain JAVA Code to your perform to business related custom setting.
  • EJB Tier is vital component of JEE application.

EIS – Enterprise Information System

  • EIS tier contains actual physical storage of data.
  • It contain RDBMS to manage the Data.
  • It Link JEE application to Resource.
  • EIS tier provides the connectivity between a JEE application and non-JEE software.

JEE API

  • Servlet
    • Java Class that generates the dynamic webpage.
    • It is something like CGI.
    • It reside on Web Tier.
    • It is server-side program which forward user request to EJB Component.
    • It also generates user response.
  • JSP  (Java Server Page)
    • It is extension of JAVA Servlet.
    • It contains HTML/XML like tag.
    • It also generate the Dynamic response.
    • It is also provide to define you own tag library.
    • It Server Side Scripting environment.
    • JSP is converted into JAVA Servlet.
  • EJB   (Entity Java Beans)
    • Enterprise Java Bean is distributed component base frame work.
    • It is a sever-side component written in Java.
    • It defines run-time environment for hosting the component of server-side.
    • It incorporates the business logic.
    • It also provides communication with DBMS.
    • EJB is been invoked by web tier component JSP/Servlet.
  • JDBC   (Java Database Connectivity)
    • It provides Data Access to RDBMS.
    • It provides platform independent and Vendor Independent Database Access.
    • It provides feature to retrieve, process, manipulate the data of database.
    • It allows to communicate with almost all RDBMS through either ODBC-to-JDBC bridge or Native Driver.
  • JMS   (Java Message Service)
    • It is a messaging standard that allows Java EE application components to create, send, receive and read messages.
    • It allows invocation of different services via messages.
    • It is just like postal system in real-life where message communicate different people (object).
  • Java Mail
    • It Provides a Platform Independent and Protocol Independent framework to build java base mail applications.
    • It Depends on “Send Mail” or “MS-Exchange” Server.
    • It enables Java programmers to communicate by sending email messages to web users.
    • These server use the POP3, SMTP to transport the Mail
  • JNDI   (Java Naming and Directory Interface)
    • It provide standard means for accessing the different types of Naming service.
    • JNDI is not a J2EE API but it belongs to J2SE.
    • JNDI help to programmer to look-up and search the objects by naming service in their Java Programs.
    • It binds the particular naming service to the object and  provide method to search to object by specified name.
    • For Ex. name and Phone in Telephone system and Domain Name System to map IP Address
  • JSF   (Java Server Faces)
    • It is a Java-based Web application framework that simplifies the development of user interfaces for Java EE applications.
    • JSF uses a component-based approach.
    • The state of UI components is saved when the client requests a new page and then is restored when the request is returned.
    • JSF uses JSP for its display technology

Web Container

In Java EE (now Jakarta EE), a web container (also known as a servlet container) is a component of the Java EE application server that manages the lifecycle of servlets and JavaServer Pages (JSP).

It handles HTTP requests, invokes servlets, and manages session data.

Containers are the interface between a component and the low-level platform-specific functionality that supports the component.

It handles deployment, management & execution support for app component.

Before a web, enterprise bean, or app client component can be executed, it must be assembled into a JEE module and deployed into its container.

It helps the developer to concentrate on his work without any concern to low-level functionality.

web container is the component of a web server that interacts with Java servlets.

A web container manages the life cycle of servlets; it maps a URL to a particular servlet while ensuring that the requester has relevant access-rights.

A web container handles requests to servlets, JSP files, and other types of files that include server-side code.

The Web container creates servlet instances, loads and unloads servlets, creates and manages request and response objects, and performs other servlet-management tasks.

Some well-known Java EE web containers include:

Apache Tomcat: An open-source implementation of the Servlet, JSP, and Java Expression Language (EL) specifications. It’s widely used and known for its performance and scalability.

Jetty: Another open-source web server and servlet container. It’s designed to be lightweight and flexible, often used in embedded scenarios.

JBoss EAP: Now known as Red Hat JBoss Enterprise Application Platform, it provides a full Java EE stack, including a web container as part of its broader application server.

GlassFish: An open-source Java EE application server that includes a web container. It’s known for being the reference implementation of the Java EE specifications.

WildFly: The successor to JBoss AS, this is a robust application server that includes a web container and supports a wide range of Java EE features.

Java EE Container Types

Web Container: It manages the execution of all JSP pages and Servlet components for Java EE app. Web components and their container run on server.

Enterprise Java Beans (EJB) container: It manages the execution of all enterprise beans for JEE app. Enterprise beans and their container run on the JEE server.

Application Client container: It manages the execution of all application client components for a Java EE app.

Applet Container: manages applet execution. It is a combination of the web browser and java plug-in running together on the client machine.

Apache Tomcat as Web Container

  • It is a Servlet container developed by the Apache Software Foundation (ASF).
  • It implements the Java Servlet and the JSP.
  • It provides a “pure Java” HTTP web server environment for Java code to run.