J2EE
John D. McGregor
Clemson University
johnmc@cs.clemson.edu

Functionality
Support for secure commerce over the Internet
Support for secure services over the Internet
Serve clients

Qualities
Flexibility
Modifiability
Reliability
Buildability
Maintainability
Performance

Basic decomposition

4-tier systems

JavaTechnologies
JDBC
JNDI
EJB
RMI
JSP
Servlets
XML

JDBC
Java Data Base Connectivity
Establishes connections among applications and databases
This may be direct or indirect
Need to be able to administer database without involving the client

JNDI
Java Naming and Directory Interface
Provides a consistent interface to enterprise wide directories

EJBs

Java Servlet
Serverside application that extends a web server
Communicates using POST and GET

Remote Method Invocation - RMI

Interface Definition Language
A language for specifying object interfaces
Uses a simplified type system
The CORBA version interfaces multiple languages

Java Transaction Architecture
A basic CORBA OTS transaction monitor

JavaMail
API for accessing mail servers

Java Messaging Service - JMS
Communicating with message-oriented middleware
Point-to-point domain
Publish/subscribe domain

Extensible Markup Language
XML
Platform independent
A number of standard tags have been developed to facilitate the transfer of information between companies

Our focus

JSP – Model 1

JSP – Model 2

JSP

JSP
<%@ page language="java" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<html>
<head>
<title>Submit example</title>
</head>

JSP
<body>
<h3>Example Submit Page</h3>
<html:errors/>
<html:form action="submit.do"> Last Name: <html:text property="lastName"/>
<br> Address: <html:textarea property="address"/>
<br> Sex: <html:radio property="sex" value="M"/>Male <html:radio property="sex" value="F"/>Female
<br> Married: <html:checkbox property="married"/>
<br> Age: <html:select property="age"> <html:option value="a">0-19</html:option> <html:option value="b">20-49</html:option> <html:option value="c">50-</html:option> </html:select>
<br> <html:submit/> </html:form> </body> </html>

Use of JSP
Person
                 FirstName  String
                 SecondName String
                 Salary     int
               ;

EJB

EJB
This is the so-called “middleware”
Comparable to the Microsoft Transaction Server and components
The “application server” provides/ or is a bean container

EJB
The J2EE security model lets you configure a Web component or
          enterprise bean so that system resources are accessed only by
          authorized users.
 The J2EE transaction model lets you specify relationships among
          methods that make up a single transaction so that all methods in one
          transaction are treated as a single unit.
 JNDI lookup services provide a unified interface to multiple naming
          and directory services in the enterprise so that application
          components can access naming and directory services.
The J2EE remote connectivity model manages low-level
          communications between clients and enterprise beans. After an
          enterprise bean is created, a client invokes methods on it as if it were
          in the same virtual machine.

EJB- Transactions
Any good database software supports a transaction model that provides
Read/write
Commit
Rollback
EJB uses Java SQL to talk to database
Database handles the actions
Trade-off: how often is data committed?

EJB - Concurrency
One bean asks whether a certain item is available. While that user makes up his mind, another bean asks the same question and quickly buys the bean. The first bean assumes that the item is still available and marks it as sold.
EJB has locking capability. Can block access by others until commit or rollback ends the transaction

EJB - Concurrency
Beans
can not create threads
Can not access threads with java.io
Can not operate directly on sockets
Can not use AWT to interact with user
Only use parameter types allowed by RMI
Must supply a no argument constructor

EJB - persistence
CMP – container managed persistence
Beans are portable
Caching happens at an aggregated level
BMP – bean managed persistence
Beans are not as portable
Caching is local

EJB Deployment
An EJB is a set of Java classes and an XML file
XML manifest locates resources that the bean will need
Specifies services that the bean offers

Web services

Web Services Models

Service view of Web services