Java U3
Java U3
Presented By
Chaithra C S
Assistant Professor
Department of Computer Applications
JSSSTU, Mysuru
Topics Covered
• The birth of J2EE,
• Databases, The Maturing of Java, Java beans and java message
service, Why J2EE
• J2EE Multi-Tier Architecture: Distributive Systems, The Tier, J2EE
Multi-Tier Architecture, Client Tier Implementation, Web Tier
Implementation, Enterprise JavaBeans Tier Implementation,
Enterprise Information Systems Tier Implementation, Challenges,
Clients, Session Management, Web Tier and Java Server Pages,
Enterprise JavaBeans Tier.
Flavors of Java
• JSE
• Java Standard Edition formerly known as J2SE.
• This forms the core part of Java language.
• JEE
• Java Enterprise Edition formerly known as J2EE.
• These are the set of packages that are used to develop distributed enterprise-scale
applications.
• These applications are deployed on JEE application servers.
• JME
• Java Micro Edition formerly known as J2ME.
• These are the set of packages used to develop application for mobile
devices and embedded systems.
• Short for Java 2 Platform Enterprise Edition. J2EE is a platform-
independent, Java-centric environment from Sun for developing, building
and deploying Web-based enterprise applications online. The J2EE platform
consists of a set of services, APIs, and protocols that provide the
functionality for developing multitiered, Web-based applications.
KEY FEATURES AND SERVICES OF J2EE
• At the client tier, J2EE supports pure HTML, as well as Java applets or
applications. It relies on Java Server Pages and servlet code to create
HTML or other formatted data for the client.
• Enterprise JavaBeans (EJBs) provide another layer where the
platform’s logic is stored. An EJB server provides functions such as
threading, concurrency, security and memory management. These
services are transparent to the author.
• Java Database Connectivity (JDBC), which is the Java equivalent to
ODBC, is the standard interface for Java databases.
• The Java servlet API enhances consistency for developers without
requiring a graphical user interface.
• The Java EE stands for Java Enterprise Edition, which was
earlier known as J2EE and is currently known as Jakarta EE. It
is a set of specifications wrapping around Java SE (Standard
Edition). The Java EE provides a platform for developers with
enterprise features such as distributed computing and web
services. Java EE applications are usually run on reference run
times such as microservers or application servers. Examples
of some contexts where Java EE is used are e-commerce,
accounting, banking information systems.
Specifications of Java EE
• Java EE has several specifications which are useful in making
web pages, reading and writing from database in a transactional
way, managing distributed queues. The Java EE contains
several APIs which have the functionalities of base Java SE
APIs such as Enterprise JavaBeans, connectors, Servlets, Java
Server Pages and several web service technologies.
Web Specifications of Java EE
• Servlet- This specification defines how you can manage HTTP
requests either in a synchronous or asynchronous way. It is low
level, and other specifications depend on it
• WebSocket- WebSocket is a computer communication protocol,
and this API provides a set of APIs to facilitate WebSocket
connections.
• Java Server Faces- It is a service which helps in building GUI
out of components.
• Unified Expression Language- It is a simple language which
was designed to facilitate web application developers.
Web Service Specifications of Java EE
• Java API for RESTful Web Services- It helps in providing
services having Representational State Transfer schema.
• Java API for JSON Processing- It is a set of specifications to
manage the information provided in JSON format.
• Java API for JSON Binding- It is a set of specifications provide
for binding or parsing a JSON file into Java classes.
• Java Architecture for XML Binding- It allows binding of xml into
Java objects.
• Java API for XML Web Services- SOAP is an xml based
protocol to access web services over http. This API allows you
to create SOAP web services.
Enterprise Specifications of Java EE
• Contexts and Dependency Injection- It provides a container to inject
dependencies as in Swing.
• Enterprise JavaBean- It is a set of lightweight APIs that an object
container possesses in order to provide transactions, remote
procedure calls, and concurrency control.
• Java Persistence API- These are the specifications of object-
relational mapping between relational database tables and Java
classes.
• Java Transaction API- It contains the interfaces and annotations to
establish interaction between transaction support offered by Java
EE. The APIs in this abstract from low-level details and the interfaces
are also considered low-level.
• Java Message Service- It provides a common way to Java program
to create, send and read enterprise messaging system's messages.
Other Specifications of Java EE
• Validation- This package contains various interfaces and
annotations for declarative validation support offered by Bean
Validation API.
• Batch applications- It provides the means to run long running
background tasks which involve a large volume of data and
which need to be periodically executed.
• Java EE Connector Architecture- This is a Java-based
technological solution for connecting Java servers to Enterprise
Information System.
Java SE vs Java EE
• Java SE refers to standard edition and contains basic
functionalities and packages required by a beginner or
intermediate-level programmer. Java EE is an enhanced
platform and a wrapper around Java SE. It has the edge over
Java SE an also has a variety of aspects in which it outshines
other features.
Birth of J2EE
• CGI (Common Gateway Interface) is a solution was adopted by many
companies with their web applications to interact with backend
services like databases.
• CGI is a program which is called when submit button action is
performed from web applications.
• CGI was able to send data from web form and hyperlink to backend
services for interacting like retrieving the information from database.
• As corporations was rely and increased in using of web application to
access their infrastructures by using CGI program it was a huge
problem faced by CGI for interfacing web applications.
Birth of J2EE
• Java team was found a solution for interacting with web applications
with corporate infrastructure by introducing servlets for creating
dynamic web pages.
• A Java servlet consists of Java classes, data, and methods, which are
callable by a browser similar to how a browser calls a CGI program.
• The main drawback of java servlet is the programmers should be
knowledgeable about java, but we programmers was known about
web programming.
• They created JSP which contains most of the code is html and less
java. Then JSP is automatically converted to java servlet.
Databases
• Many DB in the market is oracle, DB2, Informix, Sybase and other
where data is entered, stored and retrieved.
• Java team developed Java API for connection with database which
followed 2 products SQL and RDB
• The adoption of a relational database structure and SQL by the
database community simplified the task of the Java development
team. They could create one API that connected to the DBMS,
formulated a SQL statement, sent the SQL statement to the DBMS,
then received information from the DBMS, which consists of the
requested data or a message. They called this the Java Database
Connectivity (JDBC) API
The Maturing Java
• JDK provides many API’s through extensions for J2SE.
• The corporates demand was increased to web centric applications for
interactions of employees and consumers to develop independent
API’s to access server-side systems.
• For this Sun microsystems created Java Community Program which
invites all vendors, corporates, consumers to develop Standard
Enterprise Edition of Java. J2EE
Java Beans and Java Message Service
• Two services JCP implemented is Enterprise java beans and Java
Message Service for collaborative environment between vendors and
technologists.
• EJB consists of specifications and APIs for developing reusable server-
side business components designed to run on application servers.
• JMS is a standard and an API used to provide vendor-independent
communication with Message-Oriented Middleware (MOM). This
means Java programs and middleware can transact using a common
language. JMS is the first standard written for earlier technology. Until
the arrival of JMS, vendors provided their own API for messaging.
Why J2EE?
• With the onset of web-centric applications that grew more dependent
than ever on server-side technologies such as middleware, information
technology departments of corporations needed a sustainable way to
develop applications and related middleware that were portable and
scalable.
• These applications needed to be designed to handle thousands of users
simultaneously 24 hours a day. The challenge is to build the system and
test it.
• J2EE simplifies the creation of an enterprise-wide application, because
functionality is encapsulated in components of J2EE. This enables
designers and programmers to organize the application into functionality
that is distributed across the server-side components built using J2EE.
• All J2EE programs are written in Java, enabling a corporation to use its
existing staff of Java programmers to create programs that work at
each layer of the multi-tier infrastructure.
• No programmers are needed to write programs to interact with
vendor specific component.
• Java Beans, Java Servlets and JavaServer Pages are core components
of J2EE. In addition, J2EE consists of seven standard services
Unit-3 J2EE
Presented By
Chaithra C S
Assistant Professor
Department of Computer Applications
JSSSTU, Mysuru
Topics Covered
• J2EE Multi-Tier Architecture: Distributive Systems, The Tier, J2EE
Multi-Tier Architecture, Client Tier Implementation, Web Tier
Implementation, Enterprise JavaBeans Tier Implementation,
Enterprise Information Systems Tier Implementation, Challenges,
Clients, Session Management, Web Tier and Java Server Pages,
Enterprise JavaBeans Tier.
Distributive Systems
• The concept of multi-tier architecture has evolved over decades,
following a similar evolutionary course as programming languages.
The key objective of multi-tier architecture is to share resources
amongst clients, which is the fundamental design philosophy used to
develop programs.
• Software service is a program where it calls a subroutine written in
assembly level language with communicate with each other through
memory spaces, registers within the CPU of a machine.
• Subroutines are machine specific, so we need to rewrite the program.
• In Java shares the functionality by using functions instead of assembly
level language.
• Even though functions and assembly level subroutines share memory
space again program has to be recompiled and software service is
machine specific.
• Magnetic tapes were used to transfer data, programs, and software
services to another machine. There wasn’t a real-time transmission
system.
Real Time-Transmission
• Real-time transmission came about with the introduction of the UNIX
operating system. The UNIX operating system contains support for
Transmission Control Protocol/Internet Protocol (TCP/IP), which is a
standard that specifies how to create, translate, and control
transmissions between machines over a computer network.
• . Furthermore, a programmer could now call a function that was
created by a different program using a different procedural language
that resided on an entirely different machine as long as that machine
was connected to the same network
Software Objects
• Programs written in an object-oriented language were organized into
software objects—not by functionality. A software object resembles a
real-world object in that a software object encapsulates data and
functionality in the same way data and functionality are associated
with a real-world object. A software object is a software service that
can be used by a program.
Web Services
• he Internet indirectly shed new light on the conflict between these
competing protocols. The Internet is based on a set of open protocol
standards that centered on the Hypertext Transport Protocol (HTTP)
that is used to share information between machines. HTTP isn’t a
replacement for TCP/IP. Instead, HTTP is a high-level protocol that
uses TCP/IP for low-level transmission
• Three new standards were developed with the introduction of web
services. These are Web Services Description Language (WSDL),
Universal Description, Discovery, and Integration (UDDI), and Service
Oriented Architecture Protocol (SOAP).
• Many large-scale distributive systems and web services have
something in common. They are written using J2EE because J2EE
addresses the complex issues that a programmer faces when
developing a large-scale distributive system. There are numerous web
services used in a typical large-scale distributive system and each
service is associated with a tier in the multi-tier architecture that is
used to share resources over a corporate infrastructure.
J2EE Multi-tier Architecture
Tier
• A tier is an abstract concept that defines a group of technologies that provide one
or more services to its clients.
Tier
• Any resource is considered a client when a resource sends a request for service to a
service provider.
• A service is any resource that receives and fulfills a request from a client, and that
resource itself might have to make requests to other resources to fulfill a client’s
request.
• In multi-tier architecture, each tier contains services that include software objects,
database management systems (DBMS), or connectivity to legacy systems.
• Information technology departments of corporations employ multi-tier architecture
because it’s a cost-efficient way to build an application that is flexible, scalable, and
responsive to the expectations of clients.
• This is because the functionality of the application is divided into logical components
that are associated with a tier. Each component is a service that is built and maintained
independently of other services.
• Services are bound together by a communication protocol that enables a service to
receive and send information from and to other services.
• A client is concerned about sending a request for service and
receiving results from a service. A client isn’t concerned about how a
service provides the results.
• This means that a programmer can quickly develop a system by
creating a client program that formulates requests for services that
already exist in the multi-tier architecture.
• These services already have the functionality built into them to fulfill
the request made by the client program.
• Services can be modified as changes occur in the functionality
without affecting the client program.
• For example, a client might request the tax owed on a specific
order. The request is sent to a service that has the functionality to
determine the tax. The business logic for calculating the tax
resides within the service.
• A programmer can modify the business logic in the service to
reflect the latest changes in the tax code without having to modify
the client program. These changes are hidden from the client
program.
Clients, Resources and Components
• Multi-tier architecture is composed of clients, resources, components, and
containers
• In J2EE, the term “component” is used in place of the term “service,” but both
have the same philosophical meaning.
• A client refers to a program that requests service from a component.
• A resource is anything a component needs to provide a service, and a
component is part of a tier that consists of a collection of classes or a program
that performs a function to provide the service.
• A container is software that manages a component and provides a component
with system services.
• The relationship between a container and a component is sometimes referred
to as a contract, whose terms are governed by an application programming
interface (API). An API defines rules a component must follow and the services
a component will receive from the container
Clients, Resources and Components
• A container handles persistence, resource
management, security, threading, and
other system-level services for
components that are associated with the
container. Components are responsible
for implementation of business logic. This
means programmers can focus on
encoding business rules into components
without becoming concerned about low-
level system services.
• This is an important concept in multi-tier
architecture because modification can be
made to low-level security, for example,
without requiring any modification to a
component. Only the container needs to
be modified by the programmer.
• The relationship between a component and a container is very similar to
the relationship between a program and an operating system. The
operating system provides low-level system services such as I/O to a
program. Programs don’t need to be modified if a new disk drive is
installed in the computer. Instead, the operating system is reconfigured to
recognize the new disk drive.
Accessing Services
• A client uses a client protocol to access a service that is associated
with a particular tier.
• A protocol is a standard method of communication that both a
client and the tier/component/resource understand.
• There are a number of protocols that are used within a multi-tier
infrastructure because each tier/component/resource could use
different protocols.
• One of the most commonly implemented multi-tier architectures
is used in web centric applications where browsers are used to
interact with corporate online resources.
• A browser is a client and requests a service from a web server
using HTTP. In a typical enterprise-wide application, a browser
requests services from other components within
infrastructures such as a servlet.
• A servlet uses a resource protocol to access resources that are
necessary for the servlet to fulfill the request. For example, a
servlet will use the JDBC protocol to retrieve data from DBMS.
J2EE Multi-Tier Architecture
• J2EE is a four-tier architecture . These consist of the Client Tier (sometimes referred
to as the Presentation Tier or Application Tier), Web Tier, Enterprise JavaBeans Tier
(sometimes referred to as the Business Tier), and the Enterprise Information
Systems Tier. Each tier is focused on providing a specific type of functionality to an
application.
• It is important to mention the physical location and
functionality of each tier because each tier may reside in
same java virtual machine even though they perform
different functionality.
• J2EE multitier architecture is functionality centric J2EE
application only access the tiers whose functionality is
required by J2EE application
• Some APIs and j2EE components can be used on more than
one tier(XML API) , while other app is are associated with the
particular tier, like enterprise Java beans API
• The client tier consists of the programs which accepts the
input from the user and convert those inputs of the user into
the request and forward it to the software component that
process the request and return the results to the client.
• The component can operate on any tier and most of the
requests are from the client data process by the web tier
component.
• The client programme also translates server’s response into
the text and screens and present it to the user
• Web tier provides Internet functionality to the J2 ee
application.
• Components that operate on the web tier uses the
HTTP to receive the request and send the response to
the clients that can be in any tier.
• In the above figure data request from the client tier to the
web tier is initiated
• The component which is in the web tier intern request the
component which is in the enterprise Java beans tier for the
data
• Enterprise Java beans in enterprise Java beans tier interacts
with DBMS to fulfill the request
• These requests are made to the enterprise Java beans by
using the Java remote method invocation (RMI)
• The requested data is then returned to the enterprise Java
beans tier and the web tier and finally to the client tier.
• Java beans tier contains the business logic for the J2EE
application where this tier contains more than one
enterprise Java beans which contains the business rules in
order to process each request.
• The enterprise java beans tier is the keystone to every J2EE
application because EJB working on this tier enable the
multiple instances of an application to access the business
logic and the data to increase the performance.
• EJB server contains the enterprise Java beans for managing
the transaction and security and to assure the
multithreading are properly implemented when EJB is
accessed from a client.
• Enterprise Java bean can access the component on any tier
especially it access the component and resources such as
DBMS.
• These access can be made using Access Control list(ACL)
that controls the communication between the tiers.
• List are critical design element in J2EE multi-tier
architecture because it bridges the tiers that are
typically located on different virtual local area
networks.
• ACL adds security level to the web applications.
• The enterprise information system tier links J2EE
application to the resources and the legacy systems
that are available on the corporate backbone network.
Client Tier Implementation
There are components of client tier:
1) Applet Client: an applet client is a component used by web
client that operates within the applet container, which is java
enabled browser. An applet uses the browser as a user
interface.
2) Application client: it is a java application that operates within
the application client container, which is the java 2 runtime
Environment, Standard edition (JRE). An application has its own
user interface and is capable of accessing all the tiers in the
multi-tier architecture depending how the ACLs are configured,
although typically an application has access to only the web
layer.
3) Rich client: it is not considered as a component of
client tier because it can be written in a language other
than java, hence j2EE has not defined rich container.
It is similar to the application client where it has its own
interface, it can also access any tier in the environment
depending on ACL configuration like HTTP, SOAP etc.
Classification of clients