J2EE Overview
J2EE Overview
J2EE Overview
Ian Cole
Orlando Java Users Group
February 28, 2002
Presentation Overview
Introduction
to J2EE
Explain the major technologies within
the J2EE designation
J2EE applications
J2EE servers
http://java.sun.com/java2/
J2EE Technologies
Java Servlets
JSP
EJB
JMS
JDBC
JNDI
JTA / JTS
JavaMail
JAAS
XML
J2EE Components
http://java.sun.com/j2ee/overview3.html
Java Servlets
Servlets are the Java platform technology of
choice for extending and enhancing web servers.
Servlets provide a component-based, platformindependent method for building web-based
applications, without the performance limitations
of CGI programs.
http://java.sun.com/products/servlets/index.html
Java Servlets
Servlets have access to the entire family of Java
APIs, including the JDBCTM API to access enterprise
databases.
Servlets can also access a library of HTTP-specific
calls and receive all the benefits of the mature Java
language, including portability, performance,
reusability, and crash protection
http://java.sun.com/products/ servlets/index.html
Anatomy of a Servlet
http://java.sun.com/docs/books/tutorial/servlets/lifecycle/index.html
Anatomy of a Servlet
http://java.sun.com/docs/books/tutorial/servlets/lifecycle/index.html
Anatomy of a Servlet
HTTPServletRequest object
Headers
Query String
Session
Cookies
HTTPServletResponse object
Headers
Status codes
Cookies
Sample Servlet
import java.io.*;
//Apache Tomcat sample code
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloWorld extends HttpServlet
{
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter(); out.println("<html>");
out.println("<body>");
out.println("<head>");
out.println("<title>Hello World!</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Hello World!</h1>");
out.println("</body>");
out.println("</html>");
}
}
http://java.sun.com/products/jsp/index.html
Sample JSP
<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>
http://java.sun.com/products/ejb/index.html
Loading / Initialization
Transactions
Persistence
Communication with EJB clients
Enterprise Naming Context (JNDI name space)
Anatomy of an EJB
Remote Interface
Bean class
Anatomy of an EJB
EJB
New
Local
Home Interface
Beans
Session Beans
Message Beans
void
void
void
void
void
ejbCreate() {}
ejbPostCreate() {}
ejbRemove() {}
ejbActivate() {}
ejbPassivate() {}
package org.jboss.docs.interest;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
class InterestClient
{
/** This method does all the work. It creates an instance of the Interest EJB on the EJB
server, and calls its `calculateCompoundInterest()' method, then prints the result of
the calculation. */
public static void main(String[] args)
{
try {
InitialContext jndiContext = new InitialContext();
ref = jndiContext.lookup("interest/Interest");
InterestHome home = (InterestHome) PortableRemoteObject.narrow(ref,
InterestHome.class);
Interest interest = home.create(); //Create an Interest object from the Home
interface
System.out.println(interest.calculateCompoundInterest(1000, 0.10, 2));
}
catch(Exception e)
{
System.out.println(e.toString());
http://java.sun.com/products/jms/index.html
JMS Topic
http://java.sun.com/products/jms/index.html
Loosely-coupled systems
Connectionless
Removes dependence on client and server platform /
programming language / version
Send / receive information with many, unknown clients
IBM MQ-Series
Microsoft Message Queue
http://java.sun.com/products/jms/index.html
http://java.sun.com/products/jdbc/index.html
http://java.sun.com/products/jdbc/driverdesc.html
http://java.sun.com/products/ jndi/overview.html
JNDI - Layers
LDAP integration
Dynamic registration of services and clients
Peer to Peer computing
class InterestClient
{
/** This method does all the work. It creates an instance of the Interest EJB on the EJB
server, and calls its `calculateCompoundInterest()' method, then prints the result of
the calculation. */
public static void main(String[] args)
{
try {
InitialContext jndiContext = new InitialContext();
ref = jndiContext.lookup("interest/Interest");
InterestHome home = (InterestHome) PortableRemoteObject.narrow(ref,
InterestHome.class);
Interest interest = home.create(); //Create an Interest object from the Home
interface
System.out.println(interest.calculateCompoundInterest(1000, 0.10, 2));
}
catch(Exception e)
{
System.out.println(e.toString());
http://java.sun.com/j2ee/transactions.html
JavaMail
IMAP
POP
SMTP
MIME
http://java.sun.com/products/ javamail/index.html
http://java.sun.com/products/ jaas/index.html
XML
J2EE 1.3 includes JAXP 1.1 support, as well
as Servlet Filters and XML JSPTM documents.
The JavaTM API for XML Processing ("JAXP")
supports processing of XML documents using
DOM, SAX, and XSLT.
The portability and extensibility of both XML
and Java make them the ideal choice for the
flexibility and wide availability requirements of
this new web.
http://java.sun.com/xml/index.html
http://java.sun.com/xml/jaxp/index.html
J2EE Connectors
The J2EE Connector architecture defines a standard architecture for connecting
the J2EE platform to heterogeneous EISs (Enterprise Information Systems).
Examples of EISs include ERP, mainframe transaction processing, database
systems, and legacy applications not written in the Java programming language.
http://java.sun.com/j2ee/connector/index.html
J2EE Applications
http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/Oveview3.html
J2EE Deployment
Servlets
JSPs
Deployment descriptors
XML
Required for EJB JARs, WARs, EARs
J2EE Servers
Application Server
Open-source
J2EE Servers
Servlet
/ JSP Servers
Most
Suns
http://java.sun.com/products/servlet/industry.html
Wizards
Learning more
JBoss documentation
http://www.jboss.org/online-manual/HTML/index.html
Richard Monson-Haefel
OReilly 2001
Marty Hall
Prentice Hall 2000
Learning more