Unit -1: Web Application development using J2EE
Contents
1. What is J2EE
2. What
is Enterprise Architecture:
3. The J2EE Platform
4. J2EE APIs
5. Servlet :
6. JSP
7. EJB
8. JMS
9. Introduction to Containers
10. Tomcat as a Web Container
11. Configuration of Webserver
- Apache Tomcat Server
12. RMI
13. RMI Architecture
14. Developing and Executing
RMI application
• J2EE is the Java
2 Enterprise Edition
platform defined by Sun.
• J2EE is a platform-independent, Java-central
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 multitier or
Web-based applications.
• Core java
is the basic
java programming and
is called as the
J2SE(Java 2 Standard Edition.)
This is basically
used to develop standalone
programs.
• Based on
this sun has released the
J2EE(Java 2 Enterprise Edition.)This
is basically used
to develop the
enterprise applications and also web applications.
• J2EE consists of Servlets,
JSP, JDBC, EJB etc…
• J2EE can be expanded as
Java 2 Enterprise Edition that offers a development environment for enterprise
application creation and implementation.
• J2EE Architecture is made
up of three tier,
• Such as the client tier
that is used as an interactive medium for the end user or the client &
consists of web clients and application clients.
• The middle tier that is
used for defining logical functioning units & consist of web components and
EJB components.
• And the enterprise data
tier that is used for storage purposes in the form of relational database &
consists of containers, components and services.
• J2EE Architecture consist
of different architecture. And that is
• Two Tier Architecture.
• Three Tier Architecture.
• N – Tier Architecture.
• Each are clearly define
with there name
• One tier component run on
Sing client Machine
• Tow tier component run on
client as well as on database server.
• Three tier component run on
client , middleware and database server.
• N tier component require client, middleware and Multiple database.
• The J2EE platform
simplifies enterprise applications by basing them on standardized, modular
components, by providing
a complete set of
services to those
components, and by
handling many details of
application behavior automatically, without complex programming.
• The J2EE
platform enables you to assemble
applications from a combination of standard, commercially available components
and their own custom components.
• Another advantage
of the J2EE
platform is that
the application model encapsulates
the layers of
functionality in specific types
of components.
• The J2EE platform consists
of a set of services, APIs, and protocols that provide the functionality for
developing multitier, Web-based applications.
• Some of the key features
and services of J2EE is At the client
tier, J2EE supports pure HTML, as well as Java applets or applications.
• 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.
• 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 J2EE platform also
supports stand-alone Java application clients.
• NetBeans, Eclipse etc are IDE which provide J2EE Platforms.
• API is
stand for Application
Programming Interface, which is
a software intermediary
that allows two applications
to talk to
each other.
• Each time you
use an app
like Facebook, send
an instant message, or
check the weather
on your phone, you’re using an API.
• API is
set of Subroutine,
Definition, Communication
Protocol, and tools
for building software.
• A good
API makes it
easier to develop
a computer program by providing
all the building blocks.
• The API
describe and prescribes
the Expected behavior and Actual
implementation of program.
• Following is list of J2EE
API
• Servlet
• JSP
• EJB
• JMS
• JavaMail
• JSF
• JNDI
• Servlet technology is used
to create a web application.
• It is robust and scalable.
• There are many interfaces
and classes in the Servlet API such as Servlet, Generic Servlet, HttpServlet,
Servlet Request, Servlet Response etc.
• Servlet is an interface
that must be implemented for creating any Servlet.
• Servlet is a class that
extends the capabilities of the servers and responds to the incoming requests.
• It can respond to any
requests.
• Servlet is a web component
that is deployed on to the server to create a dynamic web page.
• It stands for Java Server
Pages.
• It is a server side technology.
• It is used for creating web
application.
• It is used to create
dynamic web content.
• In this JSP tags are used
to insert JAVA code into HTML pages.
• It is an advanced version
of Servlet Technology.
• It is a Web based
technology helps us to create dynamic and platform independent web pages.
• In this, Java code can be
inserted in HTML/ XML pages or both.
• JSP is first converted into
Servlet by JSP container before processing the client’s request.
• JSP technology
is used to
create web application
just like Servlet technology.
• It provides
more functionality than
Servlet such as
expression language, JSTL, etc.
• EJB (Enterprise
Java Bean) is
used to develop scalable, robust and secured
enterprise applications in java.
• Unlike RMI,
middleware services such
as security, transaction management
etc. are provided
by EJB Container to all EJB
applications.
• EJB Used When Application
need remote access.
• EJB Used When Application
need to be scalable .
• EJB Used when Application
need encapsulation business logic.
• JMS Stand for Java Message
Service.
• It is an API that provide
the facility to create, sand and read message.
• It is Technique to
communicate application or software components.
• JMS Mainly used for send or
received message from one application to another.
• JMS is a part of the Java
Platform, Enterprise Edition (Java EE).
• To implement JMS Interface,
it uses Message Oriented Middleware(MOM)
JavaMail
• The JavaMail
is an API
that is used
to compose, write
and read electronic messages
means emails.
• The JavaMail
API provides protocol
independent and platform independent
framework for sending
and receiving emails.
• The javax.mail
and javax.mail.activation packages
contains the core classes of JavaMail
API.
• The JavaMail facility
can be applied to many events.
• It can
be used at
the time of
registering the user
for sending notification such
as thanks for
your interest to
my site or forgot
password that sending
password to the
users email id or sending notifications for important updates etc.
• So there can be various
usage of JavaMail api.
JSF
• It is a server side
component based user interface
framework.
• It is used to develop web applications.
• It provides
a well-defined programming
model and consists
of rich API and tag libraries.
• The JSF
API provides components
like inputText,
commandButton etc and helps to manage
their states.
• It also
provides server-side validation,
data conversion, defining page
navigation, provides extensibility, supports
for internationalization,
accessibility etc.
• JavaServer Faces
is the Java
standard technology for building
component-based, event-oriented web interfaces.
• Like JavaServer
Pages , JSF allows
access to server-side data and logic.
JNDI
• The Java
Naming and Directory
Interface (JNDI) is an
application programming interface
(API) for accessing different kinds of naming and directory
services.
• JNDI is
similar to JDBC
in that they
are both Object Oriented Java
APIs that provide
a common abstraction for accessing services from
different vendors.
• JNDI is
not specific to
a particular naming
or directory service, it
can be used
to access many
different kinds of systems
including file systems;
distributed objects systems like
CORBA, Java RMI, and EJB.
• They provide one programming model for accessing many different products.
• A
container is a
component which can
contain other components inside itself.
It is also
an instance of
a subclass of
java.awt.Container,
java.awt.Containerextends , java.awt.Component so containers
are themselves components.
• An applet is a container.
• Other containers include windows,
frames, dialogs, and panels.
• Containers
may contain other containers.
• Every
container has a
LayoutManager that determines
how different components are
positioned within the container.
• Containers
provide an interface
between a component
and the
• low-level
platform-specific
functionality that supports
the
• component.
• Container
Type include Applet
Container , Application
Client Container, Enterprise JavaBeans
Container, Web Container etc…
• Apache Tomcat
is a Servlet
container and it is
developed by Apache Software Foundation.
• Tomcat is
used to implement
The Java Servlet and the Java Server Page.
• Servlet and
JSP are specially
used for website development as
well as web
service development.
• Web container allowed to
contain data on web.
• Apache Tomcat
provide pure java
HTTP web server environment for
java code to run.
• So Tomcat work as web container in Java Enterprise.
Configuring Apache Tomcat
Server involves several steps. Here's a basic overview of the configuration
process:
1. Download and Install
Apache Tomcat:
- Visit the Apache Tomcat website
(https://tomcat.apache.org) and download the latest stable version of Tomcat.
- Follow the installation instructions
specific to your operating system.
2. Set Environment
Variables (Optional):
- Set the `CATALINA_HOME` environment
variable to the installation directory of Tomcat.
- Add `%CATALINA_HOME%\bin` to the `PATH`
environment variable.
3. Configure Server Ports
(Optional):
- Open the `server.xml` file located in the
`conf` directory of Tomcat installation.
- Modify the `<Connector>` elements to
specify the ports on which Tomcat listens for requests (e.g., HTTP, HTTPS).
4. Configure Virtual Hosts
(Optional):
- In the `server.xml` file, you can define
virtual hosts to host multiple websites on a single Tomcat instance.
- Define `<Host>` elements within the
`<Engine>` element for each virtual host.
5. Deploy Web Applications:
- Copy your web application (WAR file) into
the `webapps` directory of Tomcat.
- Tomcat will automatically deploy the web
application and create a corresponding directory.
6. Configure Web
Application Specifics:
- Customize the configuration of each web
application by modifying the respective `context.xml` file located in the
application's directory.
- You can configure data source connections,
session management, security settings, etc.
7. Start Tomcat:
- Execute the startup script (`startup.bat`
on Windows or `startup.sh` on Unix-based systems) located in the `bin`
directory of Tomcat.
- Tomcat will start and deploy the web
applications.
8. Access the Web
Application:
- Open a web browser and access the web
application using the URL: `http://localhost:<port>/<webapp>`
- Replace `<port>` with the
appropriate port number and `<webapp>` with the name of your web
application.
These steps provide a
general overview of configuring Apache Tomcat Server. Depending on your
requirements, you may need to delve into more advanced configurations, such as
security settings, logging, performance tuning, and load balancing, among
others.
• RMI stands for Remote
Method Invocation.
• It is a mechanism that
allows object residing in one JVM system to access or invoke an object running
on another JVM system.
• RMI is used to build
distributed application.
• It provides remote
communication between java programs.
• It provided in the package java.rmi.
• The RMI provides remote
communication between the application using two object stub and skeleton.
• RMI use registry server to RPC.
• RPC means Remote
Procedure Call.
RMI (Remote Method
Invocation) is a Java-based remote procedure call (RPC) framework that allows
communication between Java programs running on different machines in a network.
RMI enables objects in one JVM (Java Virtual Machine) to invoke methods on
objects located in another JVM.
The architecture of RMI
involves the following components:
1. Stub and Skeleton:
- Stub: The client-side proxy object that
acts as a local representative of the remote object. The client interacts with
the stub as if it were the actual remote object.
- Skeleton: The server-side object that
receives method invocations from the stub, invokes the corresponding methods on
the remote object, and returns the results to the stub.
2. Remote Interface:
- A Java interface that defines the methods
that can be invoked remotely by clients. Both the client and server must have
the remote interface definition.
3. Remote Object:
- The actual implementation of the remote
interface. It resides on the server and provides the methods that can be
invoked remotely by clients.
4. RMI Registry:
- A central registry that keeps track of
remote objects available for clients to invoke.
- Clients can look up remote objects in the
registry using a unique name or identifier.
5. RMI Compiler (rmic):
- A tool that generates stub and skeleton
classes from the remote interface.
- The stub is used on the client-side, and
the skeleton is used on the server-side to handle remote method invocations.
The steps involved in
setting up and using RMI are as follows:
1. Define the remote
interface: Create a Java interface that extends the `java.rmi. Remote`
interface and includes the remote methods that can be invoked by clients.
2. Implement the remote
object: Create a class that implements the remote interface. This class will
provide the implementation of the remote methods.
3. Compile the remote
object: Use the `rmic` tool to generate the stub and skeleton classes for the
remote object.
4. Start the RMI registry: Run
the RMI registry on the server-side. The registry listens for client requests
and allows them to look up remote objects.
5. Bind the remote object
to the RMI registry: Register the remote object with the RMI registry using a
unique name or identifier.
6. Write the client
application: Create a client application that uses the stub to invoke methods
on the remote object. The client interacts with the remote object as if it were
a local object.
7. Run the server
application: Start the server application that hosts the remote object. The
server application listens for client requests and invokes the methods on the
remote object.
8. Run the client
application: Execute the client application, which connects to the server,
looks up the remote object in the registry, and invokes methods on the remote
object.
During the method
invocation, the stub on the client-side serializes the method parameters and
sends them to the skeleton on the server-side. The skeleton deserializes the
parameters, invokes the corresponding method on the remote object, serializes
the result, and sends it back to the stub, which then returns the result to the
client application.
RMI provides a transparent
mechanism for remote communication between Java objects, simplifying
distributed application development.
• In an RMI application, we
have to write two programs that is
• Server Program that is resides on the
server.
• Client Program that is reside on the
client.
• Inside the server program,
a remote object is created and reference of that object is made available for
the client using the registry.
• The client program requests
the remote objects on the server and tries to invoke its methods.
• Hear is diagram for RMI.
• Stub
• A stub is a representation or
proxy of the remote object at client.
• It resides in the client
program.
• It acts as a gateway for
the client program.
• Skeleton
• This is the object which
resides on the server side.
• Stub communicate with this
skeleton to pass request to the remote object.
• RRL (Remote Reference
Layer)
• It is the layer which
manages the references made by the client to the remote object.
• Transport Layer.
• This layer connects the
client and the server.
• It manages the existing
connection and also sets up new connection.
Thank You
::
Any Query ::
Contact:
Ruparel Education Pvt. Ltd.
Mobile
No: 7600044051
Please comment this post and Share this post to your friends.