1. Introduction to Java EE (J2EE)
Introduction to Java EE (J2EE)
Atit Patumvan, Lecturer
Faculty of Management and Information Sciences
Naresuan University
Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University.
2. 2
Introduction to Java EE (J2EE)
Model View Controller Design Pattern
● MVC is an acronym for Model View Controller
● MVC pattern separates the modeling of the domain, the presentation,
and the actions based on user input into three separate classes
● Very popular, used extensively in Java and other languages.
Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University.
3. 3
Introduction to Java EE (J2EE)
Core Elements of MVC
● Model: Contains the data model and all information that identifes
the state of the application. It is generally self-consistent and
independent of the other elements.
● View: Stands on the other side in respect to the model and defnes
the representation of the data stored in the model. The view is
commonly identifed as your application's user interface (or GUI) or, in
case of Web applications, the browser Webpage.
● Controller: Represents the application logic. Here, it is defned how
the user can interact with the application and how user actions are
mapped to model changes
Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University.
4. 4
Introduction to Java EE (J2EE)
Standard MVC Structure
Controller
notifies user interaction Handles model updates
View Model
Update the views
on model changes
Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University.
5. 5
Introduction to Java EE (J2EE)
Demo
Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University.
6. 6
Introduction to Java EE (J2EE)
What is J2EE?
Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University.
7. 7
Introduction to Java EE (J2EE)
The Java Platform
Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University.
8. 8
Introduction to Java EE (J2EE)
The Java Platform
Optional
Packages
Optional
Packages
J2ME
CDC
J2EE
J2EE Foundation Profile MID Profile
CDC CLDC Java Card API
Java Virtual Machine CVM KVM CardVM
Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University.
9. 9
Introduction to Java EE (J2EE)
What is the J2EE
● Open and standard based platform for
● Developing, deploying and managing
● N-tier, Web enabled, server-centric, and component based enterprise
application
Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University.
10. 10
Introduction to Java EE (J2EE)
What Makes Up J2EE?
● API and Technology J2EE
J2EE J2EE
J2EE
Specification Reference
specifcations Specification Reference
Implementation
Implementation
● Development and Deployment
Platform J2EE
● Standard and production-
quality implementation J2EE
J2EE J2EE
J2EE
Compatibility
Compatibility Application
Application
● Compatibility Test Suite (CTS) Test
Test
Suite
Programming
Programming
Model
Suite Model
● J2EE brand
● J2EE blueprint
● Sample Code
Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University.
11. 11
Introduction to Java EE (J2EE)
Open and Standard Solution
● Use “component and container” model in which container provides
system services in a-well defned as an industrial standard
● J2EE is that standard that also provides portability of code because it
is based on Java technology and standard-based Java programming
APIs
Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University.
12. 12
Introduction to Java EE (J2EE)
Platform Value to Developer
● Can use any J2EE implementation for development and deployment
● Vast amount of J2EE community resources
● Can use off-the-shelf 3rd party business components
Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University.
13. 13
Introduction to Java EE (J2EE)
Platform Value to Vendors
● Vendors work together on specifcations and then complete in
implementation
● Scalability, Performance, Reliability, Availability, Management and
development tools, and so on
● Freedom to innovate while maintaining the portability of application
● Do not have to create and maintain their own proprietary API
Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University.
14. 14
Introduction to Java EE (J2EE)
Platform Value to Business Customers
● Many implementation choices are possible based on various
requirements
● Price (Free to high-end), scalability (single CPU to clustered model),
reliability, performance, tools and more
● Best of breed of application and platforms
● Large developer pool
Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University.
15. 15
Introduction to Java EE (J2EE)
J2EE API and Technologies
Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University.
16. 16
Introduction to Java EE (J2EE)
J2EE 1.4 APIs and Technologies
● J2SE 1.4 (Improved) ● Servlet 2.4
● JAX-RPC (new) ● JSP 2.0
● Web Services for J2EE ● EJB 2.1
● J2EE Management ● JAXR
● J2EE Deployment ● Connector 1.5
● JMX 1.1 ● JACC
● JMS 1.1 ● JAXP 1.2
● JTA 1.0 ● JavaMail 1.3
● JAF 1.0
Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University.
17. 17
Introduction to Java EE (J2EE)
Java EE 5
● JAX-WS 2.0 & JSR 181
● Java Persistence
● EJB 3.0
● JAXB 2.0
● JavaServer Face 1.2 – new to Platform
● JSP 2.1 – Unifcation with JFS 1.2
● StAX – Pull Parser – new to Platform
Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University.
18. 18
Introduction to Java EE (J2EE)
J2EE Components
Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University.
19. 19
Introduction to Java EE (J2EE)
Java Servlet
Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University.
20. 20
Introduction to Java EE (J2EE)
What is Java Servlets
● Servlets are the Java Platform technology of choice for extending and
enhancing web server.
● Servlets provide a component-based, platform-independent method
for building web-based, without the performance limitation of CGI
Programming.
Request CGI1
Child for CGI1
Request CGI2 CGI Child for CGI2
Based Webserver
Request CGI1 Child for CGI1
Request Servlet1 Servlet Based Server
Request Servlet2 Servlet1
JVM
Request Servlet1 Servlet2
Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University.
21. 21
Introduction to Java EE (J2EE)
Java Servlets
● Servlets have access to entire family of Java APIs, including the JDBC
to access enterprise databases.
● Servlet can also access a library of HTTP Specifc call and receive all
the benefts of mature Java language, including portability,
performance, reuseability and crash protection
Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University.
22. 22
Introduction to Java EE (J2EE)
Anatomy of a Servlet
● init() – the init() function is called when the servlet is initialized by the
server. This often happens on the frst doGet() or doPut() call of the
servlet.
● destroy() – this function is called when the servlet is being destroyed
by the server, typically when the server process is being stopped.
Source: http://java.sun.com/docs/books/tutorial/servlets/lifecycle/index.html
Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University.
23. 23
Introduction to Java EE (J2EE)
Anatomy of a Servlet
● doGet() – the doGet() function is called when the servlet is called via
an HTTP GET.
● doPost() – the doPost() function is called when the servlet is called
via an HTTP POST.
● POSTs are a good way to get input from HTML forms
Source: http://java.sun.com/docs/books/tutorial/servlets/lifecycle/index.html
Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University.
24. 24
Introduction to Java EE (J2EE)
Anatomy of a Servlet
● HTTPServletRequest object ● HTTPServletResponse object
● Information about an HTTP ● Used for formatting an HTTP
request response
– Headers – Headers
– Query String – Status codes
– Session – Cookies
– Cookies
Source: http://java.sun.com/docs/books/tutorial/servlets/lifecycle/index.html
Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University.
25. 25
Introduction to Java EE (J2EE)
Demo
Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University.
29. 29
Introduction to Java EE (J2EE)
What is Java Server Pages (JSP)?
Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University.
30. 30
Introduction to Java EE (J2EE)
JSP – Java Server Pages
● JavaServer Pages technology uses XML-like tags and scriptlets written
in the Java programming language to encapsulate the logic that
generates the content for the page.
● Any and all formatting (HTML or XML) tags are passed directly back to
the response page.
● By separating the page logic from its design and display and
supporting a reusable component-based design, JSP technology
makes it faster and easier than ever to build web-based applications
Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University.
31. 31
Introduction to Java EE (J2EE)
Sample JSP: /index.jsp
01: <%@page contentType="text/html" pageEncoding="UTF-8"%>
02: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
03: "http://www.w3.org/TR/html4/loose.dtd">
04:
05: <html>
06: <head>
07: <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
08: <title>JSP Page</title>
09: </head>
10: <body>
11: <h1>Hello World!</h1>
12: </body>
13: </html>
Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University.
32. 32
Introduction to Java EE (J2EE)
EJB
(Enterprise Java Beans)
Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University.
33. 33
Introduction to Java EE (J2EE)
What is EJB technology?
● A server-side component technology
● Easy development and deployment of Java technology-based
application that are:
● Transactional, distributed, multi-tier, portable, scalable, secure, …
Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University.
34. 34
Introduction to Java EE (J2EE)
Why EJB Technology?
● Leverages the benefts of component-model on the server side
● Separates business logic from system code
● Container provides system services
● Provides framework for portable components
● Over different J2EE-compliant servers
● Over different operational environments
● Enables deployment-time confguration
● Deployment descriptor
Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University.
35. 35
Introduction to Java EE (J2EE)
EJB – Enterprise Java Beans
● Enterprise Java Beans are components that are deployed into
containers
● The container provides services
● Loading / Initialization
● Transactions
● Persistence
● Communication with EJB clients
● Enterprise Naming Context (JNDI name space)
Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University.
36. 36
Introduction to Java EE (J2EE)
EJB Architecture
Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University.
37. 37
Introduction to Java EE (J2EE)
Enterprise Java Beans
Enterprise JavaBeans
Synchronous communication Asynchronous communication
Session Bean Entity Bean Message-Driven Bean
Stateless Stateful
Bean managed Container managed
Persistence Persistence
(BMP) (CMP)
Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University.
38. 38
Introduction to Java EE (J2EE)
JMS
(Java Message Services)
Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University.
39. 39
Introduction to Java EE (J2EE)
Java Messing Service (JMS)
● Messaging systems (MOM) provide
● De-coupled communication
● Asynchronous communication
● Plays a role of centralized post offce
● Benefts of Messaging systems
● Flexible, Reliable, Scalable communication systems
● Point-to-Point, Publish and Subscribe
● JMS defnes standard Java APIs to messaging systems
Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University.
40. 40
Introduction to Java EE (J2EE)
Connector Architecture
Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University.
41. 41
Introduction to Java EE (J2EE)
m x n Problem
m n
App SAP
Server1
App
EIS2
Server2
App EIS3
Server3
App EIS4
Server
Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University.
42. 42
Introduction to Java EE (J2EE)
Connector Architecture
● Defnes standard API for integrating J2EE technology with EIS systems
● CICS, SAP, PeopleSoft, etc.
● Before Connector architecture, each App server has to provide an
proprietary adaptor for each EIS system
● m (# of App servers) x n (# of EIS's) Adaptors
● With Connector architecture, same adaptor works with all J2EE
compliant containers
● 1 (common to all App servers) x n (# of EIS's) Adaptors
Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University.
43. 43
Introduction to Java EE (J2EE)
JAAS
(Java Authentication & Authorization Services)
Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University.
44. 44
Introduction to Java EE (J2EE)
JAAS: Authentication
● Pluggable authentication framework
● Userid/password
● Smartcard
● Kerberos
● Biometric
● Application portability regardless of authentication schemes
underneath
● JAAS provides authentication scheme independent API
● Authentication schemes are specifed Login confguration fle, which will be
read by JAAS
Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University.
45. 45
Introduction to Java EE (J2EE)
JAAS Pluggable Authentication
Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University.
46. 46
Introduction to Java EE (J2EE)
Other J2EE APIs and Technologies
Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University.
47. 47
Introduction to Java EE (J2EE)
Java Naming and Directory Interface (JNDI)
● Utilized by J2EE applications to locate resources and objects in
portable fashion
● Applications use symbolic names to fnd object references to resources via
JNDI
● The symbolic names and object references have to be confgured by
system administrator when the application is deployed.
Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University.
48. 48
Introduction to Java EE (J2EE)
Java Database Connector (JDBC)
● Provides standard Java programming API to relational database
● Uses SQL
● Vendors provide JDBC compliant driver which can be invoked via
standard Java programming API.
Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University.
49. 49
Introduction to Java EE (J2EE)
J2EE is End to End Architecture
Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University.
50. 50
Introduction to Java EE (J2EE)
The J2EE Platform Architecture
B2B
Applications
Existing
Applications
B2C
Applications
Web
Services
Enterprise
Information
Wireless Application Server Systems
Applications
Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University.
51. 51
Introduction to Java EE (J2EE)
N-tear J2EE Architecture
Web Tier EJB Tier
Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University.
52. 52
Introduction to Java EE (J2EE)
J2EE Deployment
● JAR – Java ARchive
● Java class fle
● EJBs
● WAR - Web ARchive
● Servlets
● JSPs
● EAR - Enterprise ARchive
● Contains other JARs and WARs to form an entire application
● Deployment descriptors
● XML
Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University.
53. 53
Introduction to Java EE (J2EE)
J2EE Server
● Application Server
● As of Sept ’01 - MetaGroup Survey by sales $$
– BEA Weblogic - 37%
– IBM Websphere – 22%
– Oracle – 11%
– Iplanet – 5%
– Other- 12%
● Open-source
– Jboss – www.jboss.org
● Sun’s listing of J2EE compatible servers
– http://java.sun.com/j2ee/compatibility.html
Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University.
54. 54
Introduction to Java EE (J2EE)
J2EE Servers
● Servlet / JSP Servers
● Most of the commercial application servers also include servlet / JSP
support
● Open-Source
– Apache Tomcat
– Jetty
● Sun’s listing of servlet / JSP servers
● http://java.sun.com/products/servlet/industry.html
Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University.
55. 55
Introduction to Java EE (J2EE)
J2EE Development Tools
● Major IDEs support J2EE in some form
● Wizards for EJB / Servlets
● Custom editors for JSP
● Deployment descriptor support
● Deployment support for application servers
● Embedded servers for testing within IDE
Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University.