1.5 Introduction to J2EE APIs
1.5.1 Servlets:-
-
At
a high level.
-
Java
Servlets are the Java equivalent of CGI scripts.
-
That
can be used to perform processing and the servicing of client requests on a web
server.
-
From
an implementation perspective, servlets are simply Java classes.
-
That
implement a predefined interface.
-
One
use for servlets is that they can be used to dynamically generate content.
-
For
presentation to the user.
-
And
this is achieved by embedding markup language (e.g. HTML) inside the Java code.
-
As
Servlets are written in Java, they have access to the rich library of features
provided by Java.
-
Including
access to databases and other enterprise resources such as EJB.
1.5.2. Java Server Pages (JSP):-
-
JSP
is another technology for presenting information to the user over the web.
-
And
uses a paradigm where Java code is embedded into the HTML
-
The
opposite of servlets, and much like Microsoft ASP.
-
Pages
are written as HTML files with embedded Java source code known as scriptlets.
-
One
of the pitfalls in using JSP is that it is very easy to build large pages.
-
Containing
lots of embedded Java code and business logic.
-
For
this reason, JSPs provide easy integration with JavaBeans and another feature
called JSP tag extensions.
-
These
custom tags (also known as custom actions) allow re-usable functionality to be
encapsulated into XML
-
Like
tags that can be easily used on the pages by both page developers and
designers.
1.5.3 Enterprise JavaBeans (EJB) :-
-
EJB
is a major part of the J2EE specification.
-
And
defines a model for building server-side, reusable components.
-
There
are three types of enterprise beans currently supported by J2EE :
1)
Session
beans,
2)
Entity
beans and
3)
Message-driven
beans.
-
Session beans can be seen as extensions to the client
application.
-
And are typically used to model business processes.
-
There are two types of session bean :
1)
Stateful and
2)
Stateless.
-
Stateful session
beans are typically used to record conversational state for a single client
between requests.
-
Whereas stateless session beans are shared between any
number of clients at any one time.
-
Entity beans are typically used to model persistent
business entities.
-
And, in particular, data in a database.
-
A common mapping is to model an entity bean on a table.
-
There being one instance of that bean for every row in
the table.
-
There are two ways that persistence can be achieved :
1)
Container managed and
2)
Bean managed persistence.
-
In container managed persistence, a mapping is defined
at deployment time.
-
Between the persistent properties in the bean and the
columns in the table.
-
With bean managed persistence, developers write the
JDBC code that performs the create, read, update and delete operations.
-
Finally, message-driven beans allow functionality to be
executed on an asynchronous basis.
-
Typically triggered by JMS messages from
message-oriented middleware.
1.5.4 Java Message Service (JMS) :-
-
JMS
is Java API that presents an interface into message-oriented middleware such as
:
1)
IBM
MQSeries,
2)
SonicMQ
and
3)
so
on.
-
Like
JDBC, JMS provides Java applications a mechanism to integrate with such systems
by presenting a common programming interface.( Irrespective of the underlying
messaging system).
-
Functionally,
JMS allows messages to be sent and received using a point-to-point or
publish/subscribe paradigm.
No comments:
Post a Comment