® ibm software group © 2007 ibm corporation j2ee web component introduction 4.1.0.3
Post on 30-Dec-2015
212 Views
Preview:
TRANSCRIPT
®
IBM Software Group
© 2007 IBM Corporation
J2EE Web Component Introduction
4.1.0.3
2
After completing this unit, you should be able to: Understand the stages in the development of Web
applications Describe the model-view-controller (MVC) design pattern Understand the importance of MVC in J2EE applications Describe the web components and containers provided by a
J2EE platform Describe the web architecture of J2EE
After completing this unit, you should be able to: Understand the stages in the development of Web
applications Describe the model-view-controller (MVC) design pattern Understand the importance of MVC in J2EE applications Describe the web components and containers provided by a
J2EE platform Describe the web architecture of J2EE
Unit objectives
3
Web Browser
Web Server
File System
HTTP Request
HTTP Response
Client Network Server
Web Application Evolution – Static
Organizations want to make their information available to as many people in the world as possible
This can be achieved by using the Web, delivering the information as static HTML pages
4
Web Server
File System
HTTP Request
HTTP Response
Client Network Server
Web Application Evolution – Applets
With static HTML, users see passive page presentations which are always the same
Presentation can be improved with Java applets or other client-side programs
Web Browser with JVM
5
Netw
ork
Web Browser
Web Server
File System
HTTP RequestClient
Web Server Plug-in
Server
Web Container
Web Application Evolution – Servlets
Applets cannot access data on back-end systems A Web container can provide server-side components (such as
servlets) to generate dynamic content
Requests for dynamic
resources
Requests for static
resourcesHTTP Response
Dynamicresponse
6
JavaServer Page
JavaBean
RequestDispatcher
Request
Response
Web Containerservice(req,res)
methods()
methods()
forward(req,res)
service(req,res)
Web Application Evolution – JSP Pages
Servlets give poor separation between business logic and presentation logic
Use JavaServer Pages and JavaBeans to improve separation
Servlet
7
Web Application Evolution – Scalability
Business requirements often involve high availability Improved performance may be required as business grows Both these requirements can be achieved through scaling
Servers can provide redundancy in the systemBy sharing the load between servers, performance can be
enhanced
WebBrowser
HTTPServer
WebContainer
WebContainer
8
The Model-View-Controller Pattern Model-View-Controller (MVC) is a design pattern
Very widely used and regarded as a core concept in J2EE development
Various practical benefits (covered in more detail later) Promotes code reuse Reduces development time
The model Represents the underlying data and business logic in one place Contains no information about the user interface
The view The user interface – things the user can see and respond to Represent a window into the model – there can be many of these
The controller Connects the model and the view Used to communicate between the model and view
A fourth layer – persistence – is often added to the pattern
9
J2EE Server
View
Controller
Database
Model
Persistence
MVC – Application to J2EE
WebBrowser
TransferServlet Transfer
JavaBean
TransferResult
JavaBean
HTMLDoc
HTMLDoc
5
2
3
4
6
7
1
BalanceJSP
10
MVC – Benefits Promotes code reuse
The purpose of the model is to provide business logic and data access in one place
This logic can be reused in many applications at the same time without the need for any extra coding
Reduces development timeThe model, view, and controller are developed in parallel
More maintainableThe view can be changed without affecting the model
A Web page view can be changed to display a chart instead of a table with no change to the model
The model can be changed without affecting the view For example, the way in which an insurance premium is calculated
changes, but the interface to the business method remains the same
Data can be moved without affecting the view or model The layering concept allows for more flexibility
11
J2EE Introduction The Java 2 Platform Enterprise Edition (J2EE) Specification
consists of:The J2EE Platform
A standard platform of containers, services and communications
The J2EE Compatibility Test Suite To verify that a J2EE platform product complies with the standard WebSphere Application Server 6.1 is J2EE 1.4 compatible
The J2EE Reference Implementation For prototyping J2EE applications and for providing an operational
definition of the J2EE platform
The J2EE Blueprints Best practices for developing multitier, thin-client applications
J2EE is developed using the Java Community ProcessCollaboration between major enterprise software vendorsIBM actively contributes to the J2EE development process
12
J2EE Components J2EE defines different types of components which must be
supported by any J2EE productThis course will only cover Web components
Servlets and JavaServer Pages These provide the controller and view functionality in J2EE
Component deployment can be managed using deployment descriptors (except applets)
13
J2EE Containers J2EE defines different types of container.
Containers manage the components they contain.This course will only cover Web component container
Provided by a J2EE application server
J2EE components never interact with other J2EE components directlyThey depend on the run-time support of containersInteraction takes place using services provided by
containers
14
J2EE Architecture
RMI-IIOP
15
EnterpriseInformationSystemsTier
J2EE Multitier Model
RelationalDatabases
Middle TierClient Tier
EnterpriseResourcePlanningSystems
LegacyApplicationsWeb
Container(Servlets,
JSPs,HTML)
WebClient
WebClient
Firewall
16
J2EE Benefits Standards
A wide range of standard services, components, clients, and tools are supported
Applications are portable across J2EE platforms Distribution
Provides scalability for performance and availability Common services
Most commonly required services are provided by J2EE servers
Component modelGood separation of development responsibilitiesGood reuse of code and opportunities to share logic
between applications Interoperability
Integration with other systems using standard protocols
17
Checkpoint
1. What role does a servlet play in a MVC application.2. What role does a JSP play in a MVC application.
18
Checkpoint solutions
1. Servlets act as the controller in a MVC applicationa) Do not generate HTMLb) Convert the incoming HTTP information to Java objectsc) Interact with the business modeld) Forward to JSPs to render the View
2. JSP act as the Viewa) Do not contain business logicb) Simply display information
19
Having completed this unit, you should be able to: Understand the stages in the development of Web
applications Describe the model-view-controller (MVC) design pattern Understand the importance of MVC in J2EE applications Describe the web components and container provided by a
J2EE platform Describe the web architecture of J2EE
Having completed this unit, you should be able to: Understand the stages in the development of Web
applications Describe the model-view-controller (MVC) design pattern Understand the importance of MVC in J2EE applications Describe the web components and container provided by a
J2EE platform Describe the web architecture of J2EE
Unit summary
top related