Anda di halaman 1dari 16

Java Web

Application
Development
Java EE 5
J2EE Terminologies
What is J2EE?
J2EE is comprised of many APIs that can
be used to build enterprise applications.
Developing a Java EE application requires
the Java EE Software Development Kit
(SDK). The SDK contains all the tools
needed for building, testing and deploying a
software application.
MKJIT-Solutions.com
kirti.sharma@mkjit-solutions.com 2
The List of API under J2EE are:
Java Servlets
JavaServer Pages (JSP)
Enterprise JavaBeans (EJB)
Java Message Service (JMS)
Java Naming and Directory Interface (JNDI)
Java Database Connectivity (JDBC)
JavaMail
Java Transaction Service (JTS)
Java Transaction API (JTA)
J2EE Connector Architecture (J2EE-CA, or JCA)

MKJIT-Solutions.com
kirti.sharma@mkjit-solutions.com 3
What are Java Servlets?
MKJIT-Solutions.com
kirti.sharma@mkjit-solutions.com 4
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.

public void doGet(---,---)
{ // other code
out.println(<h1>Hello +username+</h1>);
}
What is JSP
MKJIT-Solutions.com
kirti.sharma@mkjit-solutions.com 5
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.
<html>
Hello
<%
session.getAttribute(username);
%>
</html>

One of the advantages of 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.

Three Tier Architecture
MKJIT-Solutions.com
kirti.sharma@mkjit-solutions.com 6



It is a clientserver architecture in which the
presentation, the application processing,
and the data management are logically
separate processes. For example,

an application that uses middleware to service data
requests between a user and a database employs multi-
tier architecture. The most widespread use of multi-tier
architecture is the three-tier architecture.
Kirti.Sharma@mkjit-solutions.com 7
Three Tier Architecture
MVC(Model-View-Controller)
Kirti.Sharma@mkjit-solutions.com 8
MVC
MKJIT-Solutions.com
kirti.sharma@mkjit-solutions.com 9
Model -represents data and the rules that
govern access to and updates of this data.
View - renders the contents of a model. It
specifies exactly how the model data should
be presented. If the model data changes,
the view must update its presentation as
needed.
Controller - The controller translates the
user's interactions with the view into actions
that the model will perform.
Three-Tier Vs MVC
MKJIT-Solutions.com
kirti.sharma@mkjit-solutions.com 10
In Three Tier : A three tier architecture is
the client tier never communicates directly
with the data tier In a Three-tier model all
communication must pass through the
middle tier
In MVC : MVC architecture is triangular: the
view sends updates to the controller, the
controller updates the model, and the view
gets updated directly from the model

Servlet Over CGI
Servlets are server side components that provides a mechanism for developing
server web applications for server side.
Earlier CGI was developed to provide server side Capabilities to the web
applications, But due to its Performance, Scalability and Reusability issues, Servlets
are preferred.
Java Servlets overcome all the issues of CGI ( Common Gateway Interface ).
Servlets are built from ground up using Sun's Write once run anywhere technology,
java servlets provide excellent framework for server side processing.
Web Developers can create fast & efficient server side applications using java
servlets and can run it on any web server which is servlet compatible.
servlets run entirely inside the java Virtual Machine.
since servlets runs on server side, it does not check for Browser Compatibility.

Servlets mainly have 5 Advantages over CGI, they are

MKJIT-Solutions.com
kirti.sharma@mkjit-solutions.com 11
Advantages of Servlets over CGI

MKJIT-Solutions.com
kirti.sharma@mkjit-solutions.com 12
Platform Independence

1) Platform Independence plays a major in the field
where there are numerous
number of web servers available to choose from.

2) Servlets are written entirely in java, due to which
they are platform independent.
Servlets can run on any servlet enabled web-server.

MKJIT-Solutions.com
kirti.sharma@mkjit-solutions.com 13
Performance


1)Due to interpreted nature of java, programs written in java are slow.
But java servlets run very fast. it is because the way servlets run on web server.

2)For any program Initialization takes significant amount of time in its life cycle.
But in case of servlets initialization takes place only once when it receives the
first request & remains in memory till times out or server shuts down's.

3) Once servlet is initialized & loaded, to handle a new request it simply creates
a new thread and runs service method of servlet.

4)In case of CGI scripts, always
a new process should be created to serve a request

MKJIT-Solutions.com
kirti.sharma@mkjit-solutions.com 14
Extensibility

1) Servlets are developed in java which is robust, well-designed & Object
oriented language which can be extended or polymorphed into a new object

2) java servlets take all java's advantages to provide the ideal solution.

Safety & Security

1) Java provides very good safety feature's like Memory management, Exception
handling etc.

2) Servlets inherit all these features & had emerged as a very powerful web
server extension.

3) Since servlets are server side Components, it inherits the security of server.

4) Servlets are also benefited with java security manager, provided by web
server.


Servlet Collboration
For sharing data, servlets need to
communicate.
RequestDispatcher & response.sendRedirect are
the two approaches for performing servlet
communication.

MKJIT-Solutions.com
kirti.sharma@mkjit-solutions.com 15
END
MKJIT-Solutions.com
kirti.sharma@mkjit-solutions.com 16

Anda mungkin juga menyukai