Comp2513 JavaBeans, EJB and J2EE Daniel L. Silver, Ph.D.

Slides:



Advertisements
Similar presentations
J0 1 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialistica in Informatica – Università di Trento.
Advertisements

J2EE Architecture Overview
Apache Struts Technology
 Copyright Wipro Technologies JSP Ver 1.0 Page 1 Talent Transformation Java Server Pages.
Using JavaServer Pages Harry R. Erwin, PhD CIT304/CSE301.
An architecture for webb applications, J2EE
Introduction to Java 2 Enterprise Edition About myself –Neutrinos, Cancer Research, IT Applications Today’s topic: J2EE –Context –Advantages –Components.
Sapana Mehta (CS-6V81) Overview Of J2EE & JBoss Sapana Mehta.
28/1/2001 Seminar in Databases in the Internet Environment Introduction to J ava S erver P ages technology by Naomi Chen.
EJB Design. Server-side components Perform –complex algorithms –high volume transactions Run in –highly available environment (365 days/year) –fault tolerant.
Outline IS400: Development of Business Applications on the Internet Fall 2004 Instructor: Dr. Boris Jukic Server Side Web Technologies: Part 2.
Java 2 – Enterprise Edition Kevin J. LaFata April 21, 2003 UM – St. Louis.
Java 2 Platform, Enterprise Edition (J2EE). Source: Computer, August 2000 J2EE and Other Java 2 Platform Editions.
J2EE vs..NET Nigam Patel. Topics Background –Web Services, J2EE and.NET Similarities Differences Conclusion –Pros and Con (J2EE and.NET)
Java Server Team 8. Overview What is a Java Server? History Architecture Advantages Disadvantages Current Technologies Conclusion.
Comp2513 Java Servlet Basics Daniel L. Silver, Ph.D.
Comp2513 Java Server Pages Daniel L. Silver, Ph.D.
1 Java Server Pages Can web pages be created specially for each user? What part does Java play?
© 2004 IBM Corporation BEA WebLogic Server Introduction and Training.
Understanding and Managing WebSphere V5
Emmanuel Cecchet et al.  Performance Scalability of J2EE application servers.  Test effect of: ◦ Application Implementation Methods ◦ Container Design.
Distributed System Using Java 2 Enterprise Edition (J2EE)
UNIT-V The MVC architecture and Struts Framework.
Chapter 10 EJB Concepts of EJB Three Components in Creating an EJB Starting/Stopping J2EE Server and Deployment Tool Installation and Configuration of.
EJB Overview Celsina Bignoli Distributed Business Applications Server DB Client DB Server DB.
Distributed Multitiered Applications The J2EE platform uses a multitiered distributed application model. Application logic is divided into components 1.
Chapter 4: Core Web Technologies
Enterprise Java Beans CS-422. Application Servers In the late 1980s and though the mid 1990s a number of corporations (Broadvision, Netscape…) marketed.
HTTP client wide area network (Internet) HTTP proxy HTTP server HTTP gateway firewall HTTP tunnel Copyright Springer Verlag Berlin Heidelberg 2004.
Glink: GCOS e-business in an application server architecture Summit 2000, Jim Gallagher.
Ing. Ignacio Roqueta ARTech GeneXus and J2EE.
Java Omar Rana University of South Asia. Course Overview JAVA  C/C++ and JAVA Comparison  OOP in JAVA  Exception Handling  Streams  Graphics User.
CS 493/693: Distributed Systems Programming V. “Juggy” Jagannathan CSEE, West Virginia University March 21, 2005.
Enterprise Java Bean Matt. 2 J2EE 3 J2EE Overview.
© 2006 IBM Corporation IBM WebSphere Portlet Factory Architecture.
第十四章 J2EE 入门 Introduction What is J2EE ?
J2EE Structure & Definitions Catie Welsh CSE 432
Enterprise Java v120131Intro to JavaEE1 Java EE 5 TM Introduction.
Enterprise Java Beans Java for the Enterprise Server-based platform for Enterprise Applications Designed for “medium-to-large scale business, enterprise-wide.
Source: Peter Eeles, Kelli Houston, and Wojtek Kozaczynsky, Building J2EE Applicationa with the Rational Unified Process, Addison Wesley, 2003 Prepared.
Databases JDBC (Java Database Connectivity) –Thin clients – servlet,JavaServer Pages (JSP) –Thick clients – RMI to remote databases –most recommended way.
1 Java EE Programming Enterprise JavaBeans. 2 Topics J2EE Overview Enterprise JavaBeans Overview Enterprise Entity Beans Case Study How to build them.
Copyright © 2002 ProsoftTraining. All rights reserved. JavaServer Pages.
Enterprise Java Beans. Model 1 J2EE – Web View Model/View/Controller Model View Control Data base Web Server Model One Architecture HTTP Request HTTP.
3/6/00jsp00 1 Java Server Pages Nancy McCracken Northeast Parallel Architectures Center at Syracuse University.
Java Servlets and Java Server Pages Norman White Stern School of Business.
Assignment of JAVA id : BSSE-F10-M-10-JAVA1 Overview of J2EE/Session 2/Slide 1 of 38.
Page 1 R MVC Design Pattern Definition Properties Describing MVC design patterns.
CS562 Advanced Java and Internet Application Introduction to the Computer Warehouse Web Application. Java Server Pages (JSP) Technology. By Team Alpha.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
Introduction to EJB. What is an EJB ?  An enterprise java bean is a server-side component that encapsulates the business logic of an application. By.
1 Distributed System using J2EE. 2 What is J2EE?  J2EE (Java2 Enterprise Edition) offers a suite of software specification to design, develop, assemble.
Java Servlets and Java Server Pages
Introduction to EJB. What is an EJB ?  An enterprise java bean is a server-side component that encapsulates the business logic of an application. By.
1 Java Server Pages A Java Server Page is a file consisting of HTML or XML markup into which special tags and code blocks are inserted When the page is.
©NIIT Introducing Enterprise JavaBeans (EJB) Lesson 1A / Slide 1 of 43J2EE Server Components Objectives In this lesson, you will learn about: The features.
Chapter 6 Chapter 6 Server Side Programming (JSP) Part 1 1 (IS 203) WebProgramming (IS 203) Web Programming.
Alan L. Batongbacal CS 4244 / 01 Nov 2000
Java Programming: Advanced Topics 1 Building Web Applications Chapter 13.
Bayu Priyambadha, S.Kom. Static content  Web Server delivers contents of a file (html) 1. Browser sends request to Web Server 3. Web Server sends HTML.
EJB Enterprise Java Beans JAVA Enterprise Edition
Glink for Java: applet, application and an API for integrating access to Bull, IBM, UNIX and Minitel systems with your Java based e-business applications.
Apache Struts Technology A MVC Framework for Java Web Applications.
2 목차 n WebLogic Architecture n J2EE Spec PreView n WebLogic Basic n Weblogic JDBC n Weblogic JNDI n Weblogic EJB Architecture n Weblogic EJB Deployment.
Speaker Name Speaker Title Speaker Title Oracle Corporation Olivier Le Diouris Principal Product Manager Oracle Corporation Building Servlet and JSP Applications.
Java Server Pages Can web pages be created specially for each user?
J2EE Platform Overview (Application Architecture)
Introduction to J2EE Architecture
MSIS 655 Advanced Business Applications Programming
Distributed System Using Java 2 Enterprise Edition (J2EE)
Presentation transcript:

Comp2513 JavaBeans, EJB and J2EE Daniel L. Silver, Ph.D.

2001Daniel L. Silver2 Objectives To understand how JSPs work with JavaBeans To understand how JSPs work with JavaBeans To review examples of JSPs and JavaBeans To review examples of JSPs and JavaBeans To introduce Enterprise JavaBeans, EJBs To introduce Enterprise JavaBeans, EJBs To describe J2EE technologies To describe J2EE technologies Paper Reference: EJP - Ch. 13, PJEC - Ch.5 Paper Reference: EJP - Ch. 13, PJEC - Ch.5 Web Reference: Servlet and JSP Programming with IBM Websphere - Chapter 5 Web Reference: Servlet and JSP Programming with IBM Websphere - Chapter 5Servlet and JSP Programming with IBM WebsphereServlet and JSP Programming with IBM Websphere

2001Daniel L. Silver3 The JSP Operational Model 1. HTTP server receives request for.jsp file 2. The.jsp file is located (can be in any directory) 3. Tomcat is called and passed the.jsp file 4. Tomcat invokes a special servlet called pageCompile (the JSP engine, comes as part of JSP distribution) 5. pageCompile builds a servlet based on JSP code (that may include a reference to a JavaBean) 6. The servlet.java and.class files are written to disk (internal to Tomcat) 7. The.class file is processed by the JVM within Tomcat like any other servlet 8. HTML code is generated by the servlet and returned

2001Daniel L. Silver4 Tomcat Java Servlet Request Processing Internet Browser Client HTTP Server HelloWorld.jsp mod_jserv Tomcat App. Server../Store05/HelloWorld.jsp HTML HelloJSP1.class../Store05/WEB-INF/classes/exampleBean/HelloJSP1 HelloWorld.java HelloWorld.class pageCompile

2001Daniel L. Silver5 Putting it all Together DateDisplay is a basic JSP that you can begin to learn from DateDisplay is a basic JSP that you can begin to learn from DateDisplay is DateDisplay is Here is a link to the JSP source Here is a link to the JSP sourceJSP sourceJSP source Here is a link to the Java source resulting from the JSP compilation Here is a link to the Java source resulting from the JSP compilationJava sourceJava source

2001Daniel L. Silver6 JavaBeans API The SUN JavaBean API provides a powerful mechanism for software reuse and automated support (e.g. introspection = beans can tell IDEs about themselves) JavaBean APIJavaBean API Defines how to write components in Java that are self- contained, reusable software units that can be visually composed into composite components, applets, applications, and servlets Defines how to write components in Java that are self- contained, reusable software units that can be visually composed into composite components, applets, applications, and servlets A JavaBean is Java.class file that contains data (properties) and methods that follow certain coding conventions A JavaBean is Java.class file that contains data (properties) and methods that follow certain coding conventions Under JSP – the use of Beans is the preferred method of separating static HTML from dynamic Java code and business logic Under JSP – the use of Beans is the preferred method of separating static HTML from dynamic Java code and business logic

2001Daniel L. Silver7 JSP useBean Tag There are standard action JSP tags that allow you to work with pre-defined JavaBeans There are standard action JSP tags that allow you to work with pre-defined JavaBeans The syntax for referencing a JavaBean within a JSP can be of two forms: The syntax for referencing a JavaBean within a JSP can be of two forms: or [option scriptlets and tags] [option scriptlets and tags]

2001Daniel L. Silver8 JSP useBean Tag The basic syntax for referencing a JavaBean within a JSP is as follows: The basic syntax for referencing a JavaBean within a JSP is as follows:<jsp:useBean id = "textProvider" id = "textProvider" class = "exampleBean.HelloJSP1" class = "exampleBean.HelloJSP1"exampleBean.HelloJSP1 scope = “request" scope = “request"/> If an instance of HellpJSP1 does not already exist then one is created If an instance of HellpJSP1 does not already exist then one is created Object name used within JSP (case sensitive) Name of the object’s implementation class See next slide

2001Daniel L. Silver9 JSP useBean Tag ScopeDescription Page Object is accessible only by single client from this page until a response is returned request Object is accessible by single client for lifetime of client request (possibly several pages) until a response is returned session Object is accessible by single client from anywhere in the application for lifetime of client session (possibly several requests). The page in which you create the Bean must have a directive with session=true. application Object is accessible by any client from anywhere in the application for lifetime of the application

2001Daniel L. Silver10 Other Useful JSP Tags Include Tag - includes the output of a servlet in a JSP Include Tag - includes the output of a servlet in a JSP Forward Tag – forwards processing from a JSP to a servlet Forward Tag – forwards processing from a JSP to a servlet

2001Daniel L. Silver11 Getting Bean Properties Other tags allow you to get or set Bean properties (data attributes) … getProperty tag: JSP code: JSP code: Java Bean (servlet) code: Java Bean (servlet) code: public String getTextMessage() { Date now = new Date(); Date now = new Date(); return "Hello World!... It is now " + now.toString() + "."; return "Hello World!... It is now " + now.toString() + "."; }

2001Daniel L. Silver12 Setting Bean Properties Using the setProperty Tag: JSP code: JSP code: Java Bean (servlet) code: Java Bean (servlet) code: public void setA(int value) { a = value; a = value; }

2001Daniel L. Silver13 JSP Bean Tags in Action Lets have a look at the useBean and getProperty tags in action within Lets have a look at the useBean and getProperty tags in action within For JSP source see (use browser’s source view) Note that the example demonstrates how a bean property value can be obtained using the getProperty tag or by an expression: Note that the example demonstrates how a bean property value can be obtained using the getProperty tag or by an expression:

2001Daniel L. Silver14 JSP Bean Tags in Action Lets have a look at the setProperty tag in action within First we set the property values of a bean “calcApB.class” using First we set the property values of a bean “calcApB.class” usingcalcApB.class Java Bean (servlet) code: Java Bean (servlet) code: public void setA(int value) { a = value; a = value; } Then we ask the bean to calculate A + B Then we ask the bean to calculate A + B

2001Daniel L. Silver15 JSP Bean Tags in Action Lets have a look at passing parameters from forms within Lets have a look at passing parameters from forms within We call another JSP “calcApB.jsp” from an HTML form passing the values of a and b We call another JSP “calcApB.jsp” from an HTML form passing the values of a and bcalcApB.jsp Within calcApB.jsp we call the bean “calcApB” and pass the values as per the JavaBean API Within calcApB.jsp we call the bean “calcApB” and pass the values as per the JavaBean API Then we ask the bean to calculate A + B Then we ask the bean to calculate A + B

2001Daniel L. Silver16 Setting Bean Properties Using a JavaBean API convention: HTML code: HTML code: Enter the value of A: Enter the value of A: Enter the value of B: Enter the value of B: </FORM> calcApB.jsp JSP code: calcApB.jsp JSP code: Java Bean (servlet) code: Java Bean (servlet) code: public void setA(int value) { a = value; a = value; } public void setB(int value) { b = value; b = value; }

2001Daniel L. Silver17 EnterPrise JavaBean Architecture EJB = Enterprise Java Bean (from SUN) EJB = Enterprise Java Bean (from SUN) EJB is at the heart of the J2EE technologies embedded within most Application Servers EJB is at the heart of the J2EE technologies embedded within most Application Servers Why yet another Java API? Why yet another Java API? –for robust, secure, distributed, persistent, transaction orient applications The goal of EJBs is to manage these issues in a standard way through reusable code The goal of EJBs is to manage these issues in a standard way through reusable code Competes with MS COM and most recently.NET Competes with MS COM and most recently.NET

2001Daniel L. Silver18 Reasons for EJB Architecture Object Distribution Object Distribution –Enterprise scale applications are distributed over geography and over different platforms –A common method of object naming (location) and transaction processing are needed –Two distributed object architectures for EJB »OMG’s CORBA – Common Object Request Broker Agent »Sun’s Java RMI – Remote Method Innvocation –EJB combines RMI with IIOP (Internet Inter-ORB Propotocal) and additional APIs to provide distributed object services

2001Daniel L. Silver19 Reasons for EJB Architecture Object Persistence Object Persistence –A persistent object is one that preserves it state (the value of its variables) across multiple invocations of the program that references that object (e.g. an order) –Maintaining state accomplished through JAVA serialization mechanism (creates a stream with an identifying serial number) –Hard part of persistence is a standard method of data storage and recall – typically using a relational DBMS –EJB allows the use of : »CMP (Container Managed Persistence) – vendor provided »BMP (Bean Managed Persistence) – user-developed

2001Daniel L. Silver20 Reasons for EJB Architecture Transactions Transactions –Transaction integrity must be maintained even when in a distributed environment with several databases –JDBC is commonly used to connect to a DBMS –How can a system be built to fully commit a transaction if and only if each DBMS says OK? –This is not easy – requires another layer of software between application and databases –Transaction monitoring embedded within EJB (JTA – Java Transaction APIs)

2001Daniel L. Silver21 Reasons for EJB Architecture Security Security –There was no set of common APIs for handling security –Authentication – Identification of a valid user –Authorization – Access to different parts of system must be restricted by user –Most solutions have been “role-your-own” –EJBs are built on a standard model that can control attribute access by specific user

2001Daniel L. Silver22 Hierarchy of EJB Types EJB Entity Bean (persistent object) Session Bean (nonpersistent) Bean Managed Persistence Container Managed Persistence Stateful (client session) Stateless

2001Daniel L. Silver23 Todays E-Commerce Apps Need the EJB Architecture Standard, portable component based architecture independent of platform or application server (well at least to some degree) Standard, portable component based architecture independent of platform or application server (well at least to some degree) Access to enterprise data and shared business logic from multuiple client types (HTML browsers, cell phones, PDAs) … XML Access to enterprise data and shared business logic from multuiple client types (HTML browsers, cell phones, PDAs) … XML Concurrent read/update to shared data by many users Concurrent read/update to shared data by many users Access to multiple disparate data sources with transactional integrity Access to multiple disparate data sources with transactional integrity Method-level security can restrict access to data by user Method-level security can restrict access to data by user Scalability to to multiple servers to handle throughput Scalability to to multiple servers to handle throughput

2001Daniel L. Silver24 J2EE Java 2 Enterprise Edition Technology is an EJB specification that includes: Java 2 Enterprise Edition Technology is an EJB specification that includes: –Programming models and APIs for developing components and web applications –A set of enterprise APIs that provide services such as transactions, naming, messaging, DBMS access –A runtime environment that can host EJB applications and functions as per the APIs

2001Daniel L. Silver25 J2EE Architecture Java 2 Standard Edition Java 2 Enterprise Edition J2EE services Web Container Servlets JSPs J2EE services EJB Container EJBs Servlets JSPs Browser Client Enterprise System

2001Daniel L. Silver26 J2EE Conforming vendors: Conforming vendors: –Jakarta - Tomcat –BEA - Weblogic AS –IBM - WebSphere AS –Sun-AOL alliance - iPlanet AS –Borland – Borland AS –Iona – iPortal AS

2001Daniel L. Silver27 J2EE API Services JNDI – JavaNaming and Directory Innterface JNDI – JavaNaming and Directory Innterface JTA – Java Transaction API JTA – Java Transaction API JDBC – Java Database Connectivity JDBC – Java Database Connectivity JMS – Java Messaging Service JMS – Java Messaging Service JavaMail – Java Mail API JavaMail – Java Mail API JAXP – Java API for XML Parsing JAXP – Java API for XML Parsing Connector – standard for connecting to enterprise applications such as ERPs Connector – standard for connecting to enterprise applications such as ERPs JAAS – Java Authentication and Authorization Service JAAS – Java Authentication and Authorization Service

2001Daniel L. Silver28 Links To the SUN Java Tutorial on Java To the SUN Java Tutorial on Java To the SUN Java Tutorial on JavaBeans To the SUN Java Tutorial on JavaBeans

THE END

2001Daniel L. Silver30 Database Connectivity via JSP WebSphere provides a number of extensions to the JSP tags … prefix is <tsx: WebSphere provides a number of extensions to the JSP tags … prefix is <tsx: We will use these JSP tags for connecting to and accessing DB2 data We will use these JSP tags for connecting to and accessing DB2 data <tsx:dbconnect id="conn" … … … …

2001Daniel L. Silver31 Database Connectivity via JSP Lets have a look at these tags in action via a JSP example that returns a request store’s name Lets have a look at these tags in action via a JSP example that returns a request store’s name Here is a servlet that does the same thing Here is a servlet that does the same thing

2001Daniel L. Silver32 Links to JSP software getProperty and method call to a bean that returns the current date and time getProperty and method call to a bean that returns the current date and time JSP form and bean combo that inputs to values A and B and calculates C = A + B JSP form and bean combo that inputs to values A and B and calculates C = A + B JSP that returns the requested stores name JSP that returns the requested stores name Servlet that does the same thing Servlet that does the same thing