0% found this document useful (0 votes)
2 views

Java U3

The document provides an overview of J2EE (Java 2 Platform Enterprise Edition), covering its birth, architecture, key features, and specifications. It discusses the multi-tier architecture, the role of various components such as JavaBeans and Enterprise JavaBeans, and the importance of Java Database Connectivity (JDBC) in enterprise applications. Additionally, it highlights the evolution of web services and the significance of J2EE in developing scalable and portable applications for distributed systems.

Uploaded by

waben61343
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Java U3

The document provides an overview of J2EE (Java 2 Platform Enterprise Edition), covering its birth, architecture, key features, and specifications. It discusses the multi-tier architecture, the role of various components such as JavaBeans and Enterprise JavaBeans, and the importance of Java Database Connectivity (JDBC) in enterprise applications. Additionally, it highlights the evolution of web services and the significance of J2EE in developing scalable and portable applications for distributed systems.

Uploaded by

waben61343
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 113

Unit-3 J2EE

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

Classification can be done on technology used to access


components and resources of each tier.
There are 5 types:
1) Web client
2) Enterprise JavaBeans client
3) Enterprise Information System (EIS)
4) Web service peers
5) Multi-tier client
• 1) Web Client: A web client consists of software, usually a
browser, that accesses resources located on the Web Tier.
These resources typically consist of web pages written in
HTML or XML.
• However, a web client can also access other kinds of
information that is located on the Web Tier. Web clients
communicate with Web Tier resources using either HTTP or
the Hypertext Transmission Protocol Secured (HTTPS), which is
used to transfer encrypted information.
2)Enterprise JavaBeans clients are similar to web clients in
that an Enterprise JavaBeans client works on the Client Tier
and interfaces the J2EE application with the user.
However, an Enterprise JavaBeans client only accesses one or
more Enterprise JavaBeans that are located on the Enterprise
JavaBeans Tier rather than resources on the Web Tier.
This access is made possible by using the (Remote method
invocation) RMI API. RMI handles communication between
the Enterprise JavaBeans client and the Enterprise JavaBeans
Tier using either the Java Remote Method Protocol (JRMP) or
the Internet Inter-ORB Protocol (IIOP).
4) EIS clients are the interface between users and resources
located on the EIS Tier. These clients use Java connectors,
appropriate APIs, or proprietary protocols to utilize resources
such as DBMS and legacy data sources.
5) a web service peer forms a peer-to-peer relationship with
other components on the Web Tier rather than a true
client/server relationship. However, a web service peer is
commonly referred to as a client because it requests service
from other components on the Web Tier, although a web
service peer can also access other tiers.
6) Multi-tier clients are conceptually similar to a web service
peer except a multi-tier client accesses components located
on tiers other than the tier where the multitier client resides.
Multi-tier clients typically use the Java Message Service (JMS)
to communicate asynchronously with other tiers.
Web Tier Implementation
• It has several responsibilities in J2EE architecture which is
provided to the client using HTTP.
• These responsibilities acts as intermediatory between the
components working on web tires and client tire as well as other
tiers.
• Intermediary activities include:-
1) accepting the request from the other software that was sent
using POST, GET and PUT operation which are part of HTTP
transmissions.
2) transmitter data such as images and dynamic content.
There are two components in web tier:
1) Servlets :
2) Java Server Pages(JSP):
Servlet
• It is a java class which is present in web tier it is called by a
request from browser in client tier. It has URL which is mapped
by servlet container.
• The request for servlet contains servlet’s URL it can be
transmitted from client tier to web tier using HTTP .
• The request creates the instance of servlet, or it reuses the
existing instance. This instance receives input parameters from
web tier which is required by servlet to process request. These
parameters were sent by client through request.
• The instance of servlet fullfill the request of client by
accessing the resources from web tier or other tiers which
are necessary based on the logic encoded to servlet.
• The servlet typically generates an HTML output stream that
is returned to the web server. The web server then transmits
the data to the client. This output stream is a dynamic web
page.
JSP
• JSP is like servlet which has URL and it is called by client.
• JSP is different than servlet in several ways depending on its
container.
• Some container translate the JSP into servlet when the client
calls JSP for first time.
• The converted JSP is compiled and compiled servlet is loaded
to memory. The servlet remains in memory
• When client calls JSP frequently causes the web server to recall
servlet without translating JSP and compiling the result code.
• Other containers precompile a JSP into a .java file that looks
like a servlet file, which is then compiled into a Java class.
• Business logic used by JSP and servlets is contained in one or
more Enterprise JavaBeans that are callable from within the
JSP and servlet.
• The code is the same for both JSP and servlet, although the
format of the code differs. JSP uses custom tags to access an
Enterprise JavaBeans while servlets are able to directly
access Enterprise JavaBeans.
Enterprise JavaBeans Tier Implementation
• The Enterprise JavaBeans Tier contains the Enterprise JavaBeans
server, which is the object server that stores and manages Enterprise
JavaBeans.
• EJB tier is vital element in J2EE architecture which provides
concurrency, scalability, lifecycle management and fault tolerance.
• EJB tier automatically handles the multiple access to same object.
• The Enterprise JavaBeans Tier is the tier where some vendors include
features that enable scalability of an application, because the tier is
designed to work in a clustered environment.
• Component containers working on the Enterprise JavaBeans Tier create
and destroy instances of components and also move components in and
out of memory.
• Collectively the Enterprise JavaBeans server and Enterprise JavaBeans
container are responsible for low-level system services that are required to
implement business logic of an Enterprise Java Bean. These system services
are:--
■ Resource pooling
■ Distributed object protocols
■ Thread management
■ State management
■ Process management
■ Object persistence
■ Security
■ Deploy-time configuration
• A key benefit of using the Enterprise JavaBeans server and Enterprise
JavaBeans container technology is that this technology makes proper
use of a programmer’s expertise. That is, a programmer who
specializes in coding business logic isn’t concerned about coding
system services. Likewise, a programmer whose specialty is system
services can focus on developing system services and not be
concerned with coding business logic.
Enterprise Information Systems Tier
Implementation
• The Enterprise Information Systems (EIS) Tier is the J2EE architecture’s
connectivity to resources that are not part of J2EE.
• These include a variety of resources such as legacy systems, DBMS, and
systems provided by third parties that are accessible to components in
the J2EE infrastructure.
• This tier provides flexibility to developers because they can use existing
systems and resources that are available
• Likewise, developers can utilize off-the-shelf software that is commercially
available in the marketplace because the EIS Tier provides the
connectivity between a J2EE application and non-J2EE software.
• This connectivity is made possible through the use of CORBA and Java
Connectors or through proprietary protocols.
Challenges
• Even though J2EE enables the programmers to design and build large-scale
distributive systems some issues must be considered.
• Resources are locked until a transaction is completed. If a transaction takes
hours together to complete then there will be an issue for other components
which are waiting to access the resources.
• Reliability is also an issue when a resource within a corporate environment is
offline, at the time the system requires database access.
• Java applications must provide proper error-handling routines. It’s up to the
developer to provide a graceful response to an error condition. The developer
must also be aware of possible Runtime Exceptions that may be thrown during
the execution of a program.
• Security becomes an issue. Even if access to resources is made using HTTP and
Secured Sockets Layer (SSL), another security level is needed to assure that only
authorized systems have access to the resource
An Enterprise Application
The enterprise application
• The term enterprise application is exclusive since practically any
application used by more than one person to conduct business could be
considered an enterprise application.
The purpose of J2EE considered an enterprise application to be one that:
• Is concurrently used by more than a handful of users
• Uses distributive resources such as DBMS data shared with other
applications
• delegates responsibility to perform functionality among distributive
objects
• uses web services architecture and J2EE technology to link together
components that are dispersed throughout the corporate infrastructure.
Corporate users having high expectations from an enterprise
application:
• The application has to be available 24 hours a day 7 days a
week.
• Have an acceptable response time even in face of increasing
usage.
• Have the flexibility to be modified quickly without requiring
the redesign of the application.
• Be vendor dependent.
• Be able to interact with existing system.
• Utilise existing system components.
• Search developers have to create an enterprise application
that is available and scalable to adjust to increase and
decrease in demand. the application must extensible and
maintainable so new business rules can be easily added to
the application.
Clients
In multi-tier architecture of J2EE client there is a first tier which
contains a software working on the client tier as several
functionalities. However, there are few functions that are less
initiative to the programme and therefore pose a challenge to
the programmers.
• Present applications user interface to the person who is using
the application.
• Correct and validate the information from the person using the
application.
• Control the clients access to the resources.
• Prevent clients from sending duplicate request.
Client Presentation
• Application uses client model where all the functionality
associated with the applications this content on the server
side than with the client.
• Handle the user interface that present information to the
user and captures input from the user.
• There are 2 strategies for building presentation functionality
into the client.
a) Browser-based user interface
b) A rich client
Browser-based user interface
• It is written in HTML r XML which is used by XML enabled browser to
interact with the user.
• It is easy to implement the presentation layer of enterprise
application.
It also has disadvantages:
• the developer doesn't have exact control over the presentation to
the user insert developer only suggests the browser with font, colour,
position off text etc.
• The browser-based strategy is the presentation his limited to the
interaction that can be implemented using markup language or
plugin its limits the design of the user interface.
• Another disadvantage is the presentation lyrics server-side
dependent this means the application accesses the server
more than if a richer client strategy was used to create a user
interface.
Richer Client Strategy
Richer client strategy gives a developer total control over the
elements of the presentation an event trapping.
The richer pain access the server only as needed and not in
response to nearly every event at occurs in the presentation.
Client Input Validation
• Commercial entered by the user should be validated.
Validation process and application dependent. Validation can
occur either on the client side or server side.
• The developer can implement 3 kinds of validation
strategies:
a) Syntactic Validation
b) Lexical Validation
c) Semantic validation
a) Syntactic Validation: he determines if the information that
consists of several related values is well formed. Example: time as
composed of hours and minutes.
b) Lexical Validation: it validates whether the type of the value
and the type of the data are of same type. Example: value of hour
must be integer
c) Semantic Validation: it determines if the value of the hour is
less than 24 and greater than or equal to zero.
The 3 fundamental factor that must be considered wild
designing validation procedures.
• Avoid duplicating the validation procedure
• provide the user with immediate result of validation
process
• minimise effect the validation process has on the server
Client control
• In every enterprise application clients are restricted to
resource based on the client’s needs. The scope of the resorts
a client can access is commonly referred to as a client view.
• A client view might consist of specific database tables or rows
and columns of the tables.
• There are 2 ways for a client view to be defined:
a) through the embedding logic to define the view and to the
application.
b) By using a controller component that is known as a resource
guard.
• The resource guard is the component that resides outside of
the application that receives the request for the resources
from all the applications.
• The request for the resource contains a client ID that is
compared to the client’s configuration.
• Axis is granted or rejected based upon the access rights
within the client configuration.
• The best practice is to use the security measures that exist in
DBMS or networks.
• Guard is a component that is shared with other applications therefore
the developer must construct a resource guard using one of the
techniques used to share the code within J2EE. 3 or of the more
common ways are to build a resource guard using a Java server pages,
servlet or enterprise Java beans.
• The client view was defined the developer must determine a
strategy for implementing the client view
• there are 2 commonly used strategies:
a) All-are-nothing strategy: this strategy allows the developer
to write logic that enables or prevents a client from
accessing the complete resources
b) selective strategy: this strategy grants a client access to the
resource but restricts access to the selected features of the
resource based on the client’s needs.
Duplicate Client Requests
• Common problem within the client application is a client can
submit a duplicate request for service such as submitting a
duplicate order through browser interface.
• Browser interface used in a thin client application. However,
the browser contains elements that can lead to a duplicate
request being sent namely a back and stop buttons.
• Hey back button causes the browser to recall the previously
displayed webpage from web server.
• The stop button halts the implementation of a request this
means the browser processor some but not all of the request.
• Best practice to avoid the duplicate submission of flushing
the session explicitly and updating the session object
without waiting for the page to complete.
Session Management
• The best application consists of distributive services located on J2 ee
tiers shared among the applications.
• Session begins with an initial request for the service and ends on
once the client no longer requests the service.
• During the session a client and the components exchange the
information which is called the session state
• the kind of the information can be session state including clients ID
profile are the choices a client makes in a web form.
• A component is an entity whose soul purpose is to receive the
information from the client process that information and return the
information to the client when necessary.
Client-side session state

• Sessions can be maintained by the client rather on the server


using one or the combination of 3 techniques:
a) Using a hidden fields in HTML form
b) rewriting URLs
c) using cookies
• Application contains HTML form to collect the information from
the user. HTML contains many elements such as text fields and
buttons. Text fields displays the instructions of the form and title
of the form.
• Afield is a place on the form where a user enters the data each
field has name that uniquely identifies the field and the value.
• Example drop down combo boxes, radio buttons check boxes
etc.
• Where you select the submit button the browser extracts the
field names and the field values from the farm and assembles
them into a query string.
• The browser then call the components and the web tier which is
usually a JSP program or a servlet and passes the field names
and field values as parameters to the component
• the component then process this information. once processing
is completed the component dynamically generates a web page
that may contain another form depending on the nature of the
application
Hidden Field
• The component can include HTML form a field that does not displayed on
the form. This field is called a hidden field.
• Hidden field are similar to the other fields in the HTML form which
doesn't hold a value.
• This value is assigned to the hidden field by the component rather than
the user.
• Hidden field is treated as same as other fields on the form when the user
select the submit button.
• That is the name of the hidden field, and the value of the hidden field are
extracted from the form along with other fields by the browser and sent
as a parameter to the component.
Hidden fields contain only string values and not numeric dates
and other data types which means the complaint might need to
convert the string values into more appropriate value each time
the page is sent to the component.
URL Rewriting

• Rewriting is another strategy for maintaining the sessions state.


• An URL is an element within the web page that uniquely identifies the
component and is used by the browser to request a service.
• The browser can attach to the URL field names and field values that
are passed the component if the component requires this information
to process the request.
Cookies
• Amount of data that the enterprise application stores on the clients
machine a cookie can be used to store the session state.
• The developer can create a JSP program that dynamically generates a
page that writes and reads one or more cookies Hindus way the
session persists between the pages.
• There are 2 major disadvantages of using cookies to retain the session
state:
a) cookies can be disabled there by prohibiting the enterprise
application from using a cookie.
b) Cookies can be shared among us trainer stances. All the instances
access the same cookie and therefore the same session state which
is likely to cause a conflict between processing the information.
Server-Side Session State
• Storing session state on client side has serious drawbacks
because dependency on client’s machine. i.e a session state is
lost if client machine fails.
• An alternative to maintaining session state on the client side is
to store session state on the server or on the web tier using the
HTTP session interface.
• Each session is assigned a session ID which relates the session
state with a particular client session.
• This provides the most reliable way to save an access decision
state and is scalable thereby able to handle the multiple sessions
and various sizes of session state.
Replication Servers
• Enterprise application consists of replication servers where
server has full of complement of components. Whenever the
request is received from the client the request is routed to
the next available server within the cluster. In this way
hundreds of requests are received simultaneously can be
acceptable and maintained.
• When multiple servers are present there will be a problem to
know which server has session state.
• This problem can be managed using two strategy:-
• To replicate session state across all servers within the cluster
• Route a client to the same server for the duration of the session.
Best Practice: the best practice to maintain the session state is to
always use the same server during the session and the session state is
stored on one server within the cluster.
Valid Session State
Another issue that is common with an enterprise application is
the session state stored on server is whether or not the
session state is valid. Session state automatically becomes
invalid and removed when the session ends. However there
might be occasions when the session ungraceful terminates
without removing the session state such as during
communication failure that occurs during the session.
Best Practice: best practices to always set a session time out
which automatically invalidates the session state after time
has passed and the session state has not been accessed.
Web Tier and Java Server Pages
• Web tier contains the components that directly communicate
with clients. The Web tier is also the location where the Java
server pages programme reside. JSP are common proxy to an
application server as implemented by the tomcat and WebLogic.
• This is practically good technique to use when vertically scaling
your application because it provides additional security.
• JSP program is a component which provides service to the client.
• JSP program is identified with the URL that is associated with the
hyperlink built into a web page displayed on the client.
• When user selects the hyperlink the browser cause a JSP
program which executes a JSP statements.
• A JSP programme receive order information that a browser
extracted from a HTML order form and pass it to the JSP
program. The JSP program uses the information received
from the browser to process the order by calling one or more
enterprise Java beans. Once processing is completed the JSP
program generates a dynamic web page that serves as a
confirmation of the order.
Presentation and Processing
• JSP programme contains 2 components:
a) Presentation component: the content that is displayed by the
client
b) Processing Logic: it defines the business rules that are applied
whenever the client calls JSP programme
• Placing both presentation and processing logic companies
together seems non maintainable because of 2 reasons
1) presentation processing logic components tend to become
complex and difficult to comprehend specially when a code
contains the mixture of HTML and Java scriptlets.
2) The other reason is the programmers with different skills it's
typically right each component.
• The best practice for presentation and processing is to
writing a JSP program to separate the presentation code and
the processing code.
• Place the presentation code in the JSP program and place the
processing code in the enterprise Java beans.
There are many advantages by following this strategy:
• JSP program is easier for a programmer since processing
logic as no longer resides in JSP programme
• The task is divided along discipline lines. HTML programmer
can focus on creating JSP programme while Java programmer
builts enterprise Java beans, both runs in parallel.
The Inclusion Strategy
• While listening the enterprise application same elements has been
used for all the web pages for the user interface. The same code
can appear more than once in web page which is insufficient for
the maintenance.
• When multiple JSP programme generate the web pages, the
developer has to identify and change each JSP programme that
generates web page each time, changes made to an element that is
common to all the pages.
• The best practice to avoid above problems is to avoid threaded
code by inclusion strategy which uses either the include directive
or include action to insert commonly used code into a JSP program.
Style Sheets
• It is important that enterprise applications user interface is
consistent throughout the application.
• Consistency helps a user to become familiar with how to use the
application.
• It means that the developer must write a JSP program that generate
the web pages having the same general appearance.
• Consistency therefore for requires that each web page contains
error and code that defines the web page style and mentioned in
the previous section redundant code leads to maintenance
headaches.
• The best practice is to enforce the continuity among the web
pages that comprise an application’s user interface is to use
the cascading style sheet. CSS is a file that describes the style
of elements that appear on the web page.
• the developer test the client to reference the CSS file by
using the CSS directory in the web page. The browser then
automatically applies a style define in the CSS file to the web
page that consists of the CSS directives. CSS file can be easily
modified to change the appearance of the web page.
Simplify Error Handling
• The enterprise application should trap the errors at occur at runtime
using techniques that are available in Java. However it is important
that is the application translate raw error message into the text that
is understood by the user of the application.
• Error can occur throughout the application, JSP program or servlet
should present error to the users. Enterprise Java beans called by JSP
programme catches the error. One the error is trapped the
enterprise Java beans forward error message to the JSP program.
• JSP programme translate the error message into the message easily
understood by the user and then display the translated error
message in a dynamically generated web page.
• Best practice for handling the error is to generate a user-
friendly error message that reflects the processing that was
executing when the error occurred.
• Another best practice while handling the errors is to have
either the JSP programme or the enterprise Java beans to
save all error messages and related information.
Enterprise Java Beans Tier
• EJB Tyre provides a processing logic to the others. Processing logic
includes all the code and data that is necessary to implement one or
more business rules.
• The purpose of creating enterprise Java bean is to encapsulate the
code that performs one task very well and to make that code
available to any application that needs that functionality.
• Even though it is easy to understand the enterprise Java beans there
will be a confusion while designing the Java beans into application
specific.
• The developers needs to decide which functionality should be built
into the enterprise Java bean.
• Sample an online order entry application must determine if the
customer state is good or bad before the customer order is
processed.
• The business logic requires application to verify the customer
status is good before placing the order.
• 2 database task must be performed here, and each task has its
own enterprise Java beans.
• How are both Java beans called? and should both task be
included in one Java enterprise Java beans?
• The best practice is to make enterprise Java bean self-contained
and minimise interdependence of Jai enterprise Java beans
where possible.
Entity to Enterprise JavaBeans Relationship
• developers has to create one to one relationship between the
entities defined in an application’s entity relationship diagram
hand with the enterprise Java beans.
• Each entity has its own entity enterprise Java beans that contains
all the processing logic required by the entity.
• Creating one to one relationship tends to generate many
enterprise Java beans and therefore it increases the overhead
and also results in lower performance.
• Hence the best practice is to translating entity relationship
diagram into enterprise Java beans is to consolidate the related
processes that are associated with several entities into one
session enterprise Java beans.
Efficient Data Exchange
• Jain enterprise Java beans frequently exchange information while
enterprise application is executing.
• JSP program might pass the information received from the client to the
enterprise Java beans. Enterprise Java might return the value to the
JSP programme once processing is completed.
• Two common ways in which the information is exchanged between JSP
program and enterprise Java beans.
• These are individually sending and receiving each data element or by
using the value object to transfer the data in the bulk.
• Best practise for exchanging the information between a JSP program
and enterprise Java beans seeds to use a value object.
Enterprise java beans performance
• Enterprise Java beans provide an efficient way to process the
business role in distributed system.
• Enterprise java beans remains vulnerable to bottlenecks that occur
when the enterprise java beans communicate with other
components. bottlenecks effectively decreased efficiency of
implementing enterprise Java beans.
• Communication occurs between enterprise Java beans and other
components the higher likelihood debt bottlenecks will occur.
• The best practice is to keep remote communication to the
minimum needed to exchange information and to minimise the
duration and any communication.
Model View Controller(MVC)
• Developing enterprise application is complex undertaking
because application must be capable of serving many diverse
clients simultaneously were distributed infrastructure.
• The application must be scalable so that the application can
continue to provide the acceptable performance regardless of
the increase in number of clients who use the application.
• The best practice for simplifying the distribution of an
application functionality is to use the model view controller
stratergy that is endorsed by the sun microsystem.

You might also like