CSC584 Enterprise Programming Chapter 2
CSC584 Enterprise Programming Chapter 2
Programming
Chapter 2 – Introduction to Java Enterprise Edition
MARSHIMA MOHD ROSLI
FA C U LT Y O F C O M P U T E R & M AT H E M AT I C A L S C I E N C E S , U I T M S H A H A L A M
• Overview of Java EE Platform
• Role of Application Servers
• Java EE Architecture (MVC, Spring)
Chapter • Java EE Patterns
Outline
• Java EE Components (Web components, EJB)
Past History
Initially two tier architecture (client server applications)
Client is responsible for data access applying business logic and
presentation of data
Only service provided by Server was that of database server.
Drawbacks
- Easy to deploy but difficult to enchance
or upgrade.
- It makes reuse of business and
presentation logic difficult
- Not scalable and not suited for internet
Java EE Platform
Java EE is an architecture
for implementing
enterprise class
applications using Java
and Internet Technology
- Solves problems of two
tier architecture
Overview of Java EE Platform
Java Platform
• A Java platform comprises the JVM together with
supporting class libraries.
• managing
Web
server My codes
PHP
HTTP HTML MySQL
interpreter
Client
Operating System
Web
TCP/IP
browser
Operating
System
Internet
Historically (Java Web App)
Server: response
• Webserver supports HTTP. Server
<html>
<head>
GET... GET...
</head>
<body>
...
Web
Container Servlet
Application (Java code)
HTTP <html> (Java code)
Client <head>
</head>
<body>
...
<body> Operating System
</html>
Web
TCP/IP
browser
Operating It’s the Container that gives
System the Servlet the HTTP request
and response, and it’s the
Container that calls the Servlet’s
Internet methods (e.g. doPost() or doGet())
Historically (Java Web App)
Server: response
• Webserver supports HTTP.
Server
<html>
<head>
GET... GET...
</head>
<body>
...
Servlet
HTTP (Java code)
<html>
Client <head>
</head>
<body>
...
<body> Operating System
</html>
Web
TCP/IP
browser
Operating
System It’s the Container that gives
the Servlet the HTTP request
and response, and it’s the
Container that calls the Servlet’s
Internet methods (e.g. doPost() or doGet())
(Java Web App) Server: response
• Webserver supports HTTP.
Server
GET...
Grizzly is now the Web server + <html>
<head>
</head>
http://java.sun.com/docs/books/tutorial/servlets/lifecycle/index.html
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
http://java.sun.com/docs/books/tutorial/servlets/lifecycle/index.html
©The McGraw-Hill Companies, Inc.
Permission required for CHAPTER 8 - 43
JSP – JavaServer 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.
http://java.sun.com/products/jsp/index.html
<html> <!- Apache Tomcat
Samples ->
<!-- Copyright (c) 1999 The Apache Software Foundation. All rights reserved.-->
<body bgcolor="white">
<jsp:useBean id='clock' scope='page' class='dates.JspCalendar'
type="dates.JspCalendar" />
<font size=4><ul>
<li> Day of month: is <jsp:getProperty name="clock"
property="dayOfMonth"/>
<li> Year: is <jsp:getProperty name="clock" property="year"/>
<li> Month: is <jsp:getProperty name="clock" property="month"/>
<li> Time: is <jsp:getProperty name="clock" property="time"/>
<li> Date: is <jsp:getProperty name="clock" property="date"/>
<li> Day: is <jsp:getProperty name="clock" property="day"/>
<li> Day Of Year: is <jsp:getProperty name="clock" property="dayOfYear"/>
<li> Week Of Year: is <jsp:getProperty name="clock"
property="weekOfYear"/>
<li> era: is <jsp:getProperty name="clock" property="era"/>
<li> DST Offset: is <jsp:getProperty name="clock" property="DSTOffset"/>
<li> Zone Offset: is <jsp:getProperty name="clock" property="zoneOffset"/>
</ul>
</font>
</body>
</html>
Enterprise JavaBeans (EJB)
Enterprise JavaBeans container handles:
• distributed communication
• threading
• scaling
• transaction management, etc.
Enterprise JavaBeans
Stateless Stateful