MACROMEDIA JRun 4 Getting Started Manual

Getting Started
with JRun
Trademarks
Afterburner, AppletAce, Attain, Attain Enterprise Learning System, Attain Essentials, Attain Objects for Dreamweaver, Authorware, Authorware Attain, Authorware Interactive Studio, Authorware Star, Authorware Synergy, Backstage, Backstage Designer, Backstage Desktop Studio, Backstage Enterprise Studio, Backstage Internet Studio, ColdFusion, Design in Motion, Director, Director Multimedia Studio, Doc Around the Clock, Dreamweaver, Dreamweaver Attain, Drumbeat, Drumbeat 2000, Extreme 3D, Fireworks, Flash, Fontographer, FreeHand, FreeHand Graphics Studio, Generator, Generator Developer's Studio, Generator Dynamic Graphics Server, JRun, Knowledge Objects, Knowledge Stream, Knowledge Track, Lingo, Live Effects, Macromedia, Macromedia M Logo & Design, Macromedia Flash, Macromedia Xres, Macromind, Macromind Action, MAGIC, Mediamaker, Object Authoring, Power Applets, Priority Access, Roundtrip HTML, Scriptlets, SoundEdit, ShockRave, Shockmachine, Shockwave, Shockwave Remote, Shockwave Internet Studio, Showcase, Tools to Power Your Ideas, Universal Media, Virtuoso, Web Design 101, Whirlwind and Xtra are trademarks of Macromedia, Inc. and may be registered in the United States or in other jurisdictions including internationally. Other product names, logos, designs, titles, words or phrases mentioned within this publication may be trademarks, servicemarks, or tradenames of Macromedia, Inc. or other entities and may be registered in certain jurisdictions including internationally.
This product includes code licensed from RSA Data Security.
This guide contains links to third-party websites that are not under the control of Macromedia, and Macromedia is not responsible for the content on any linked site. If you access a third-party website mentioned in this guide, then you do so at your own risk. Macromedia provides these links only as a convenience, and the inclusion of the link does not imply that Macromedia endorses or accepts any responsibility for the content on those third-party sites.
Apple Disclaimer
APPLE COMPUTER, INC. MAKES NO WARRANTIES, EITHER EXPRESS OR IMPLIED, REGARDING THE ENCLOSED COMPUTER SOFTWARE PACKAGE, ITS MERCHANTABILITY OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. THE EXCLUSION OF IMPLIED WARRANTIES IS NOT PERMITTED BY SOME STATES. THE ABOVE EXCLUSION MAY NOT APPLY TO YOU. THIS WARRANTY PROVIDES YOU WITH SPECIFIC LEGAL RIGHTS. THERE MAY BE OTHER RIGHTS THAT YOU MAY HAVE WHICH VARY FROM STATE TO STATE.
Copyright © 2002 Macromedia, Inc. All rights reserved. This manual may not be copied, photocopied, reproduced, translated, or converted to any electronic or machine-readable form in whole or in part without prior written approval of Macromedia, Inc. Part Number ZJR40M200
Acknowledgments
Project Management: Randy Nielsen Writing: Rosemary Marano Editing: Linda Adler and Noreen Maher
First Edition: May 2002
Macromedia, Inc. 600 Townsend St. San Francisco, CA 94103
CONTENTS
ABOUT THIS BOOK . . . . . . . . . . . . . . . . . . . . . . . . . . . VII
Developer resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . viii
About JRun documentation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix
Printed and online documentation set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix
Accessing online documentation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix
Other resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .x
Contacting Macromedia . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiv
Part I Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
CHAPTER 1 Welcome to JRun . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
About JRun. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4
Benefits of server-side Java . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4
Benefits of using J2EE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5
J2EE standards compliance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6
JRun architectural model. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7
JRun features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8
Development tools. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13
Dreamweaver MX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13
Using JRun with your Java IDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13
Installing the Enterprise Deployment Wizard in your Java IDE . . . . . . . . . . . . . . . . . . . .13
What to do next . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14
CHAPTER 2 JRun Programming Model . . . . . . . . . . . . . . . . . . . . . . 15
Enterprise application architecture. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .16
Enterprise application design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .16
J2EE application architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .16
JRun support for the three-tier model. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18
JRun programming environment. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .19
JRun servers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .20
Using JRun servers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .20
Starting and stopping JRun servers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .21
Installed JRun servers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .22
Web servers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .25
JRun Web Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .25
JRun support for J2EE applications. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .26
About web applications and JRun. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .27
iii
About EJBs and JRun. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .27
About enterprise resource adapters and JRun . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .28
About enterprise applications and JRun . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .28
CHAPTER 3 Introduction to J2EE . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
J2EE environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .30
J2EE platform technologies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .31
Components. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .31
Containers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .31
Communication. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .32
J2EE APIs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .33
EJB 2.0. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .33
Java Database Connectivity 2.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .34
Java Servlet 2.3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .34
JavaServer Pages 1.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .34
Java Message Service 1.0. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .34
Java Transaction API 1.0 and Java Transaction Service. . . . . . . . . . . . . . . . . . . . . . . . . . .34
JavaMail 1.2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .35
JavaBeans Activation Framework 1.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .35
Java API for XML 1.1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .35
J2EE Connector API 1.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .35
Java Authentication and Authorization Service 1.0. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .36
Java Naming and Directory Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .36
Common Object Request Broker Architecture compliance. . . . . . . . . . . . . . . . . . . . . . . .36
Additional resources. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .36
CHAPTER 4 Using Servlets and JSP . . . . . . . . . . . . . . . . . . . . . . . . . 37
Using Java Servlets. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .38
Invoking servlets. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .38
Servlet benefits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .39
Creating servlets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .40
JRun support for servlets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .40
JRun support for JSPs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .40
Servlets and JSPs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .41
HTTP requests and responses. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .41
Writing results back to the client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .42
Using servlet filters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .42
Using event listeners . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .43
Handling exceptions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .43
Maintaining page context information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .43
Working with sessions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .44
Tracking an application’s context . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .44
Accessing configuration information. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .45
Writing servlets in Java. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .45
Writing servlets as JSPs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .46
CHAPTER 5 Introduction to EJB . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
EJB Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .48
The parts of an EJB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .48
Container services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
iv Contents
EJB types. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .49
Session beans . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .49
Entity beans . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .50
Message-driven beans . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .51
Using EJB in JRun. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .52
Stubless deployment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .52
Deployment options. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .52
EJB clustering. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .52
XDoclet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .53
The Enterprise Deployment Wizard. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .53
CHAPTER 6 Developing Web Applications . . . . . . . . . . . . . . . . . . . . 55
Introduction to web applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .56
The benefits of web applications. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .56
Comparing web applications and enterprise applications . . . . . . . . . . . . . . . . . . . . . . . . .56
Using web applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .57
About the web application directory structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .58
The deployment descriptor (web.xml) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .59
Web applications, JRun servers, and web servers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .60
Mappings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .60
Application mappings. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .61
Developing web applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .62
Creating a web application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .62
Adding web application components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .62
Deploying web applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .65
Deploying a web application across a cluster. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .65
Packaging a web application for deployment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .66
Part II Tutorials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
LESSON 1 Servlet Tutorial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
Setting up the development environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .70
Getting started with JRun . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .71
Adding a JRun server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .72
Deploying the tutorial enterprise application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .75
Adding JDBC data sources. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .76
Compass Travel J2EE application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .80
Coding the logon servlet. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .80
Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .82
What’s next?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .82
LESSON 2 JSP Tutorial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
Creating a home page JSP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .84
Compass Travel tutorial application. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .84
Accessing a JavaBean . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .86
Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .88
What’s next?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .88
LESSON 3 EJB Tutorial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
C o n t e n t s v
Using EJBs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .90
Invoking an EJB from a JSP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .91
Booking a trip reservation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .93
Examining the code for the reservation EJB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .93
Examining the code for the credit card EJB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .94
Examining the code for the order EJB: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .94
Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .95
Tutorial lessons summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .95
What’s next?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .95
LESSON 4 Web Services Tutorial . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
Using JRun web services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .98
TravelNet web services application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .98
Setting up the development environment. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .99
Getting started with JRun . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .100
Adding a JRun server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .101
Deploying the TravelNet enterprise application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .104
Authoring a web service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .105
Generating WSDL from a published web service. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .106
Generating a web service proxy client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .108
Creating and using a JSP-based proxy client. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .110
Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .113
INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .115
vi Contents
ABOUT THIS BOOK
Getting Started with JRun is for anyone using JRun to develop applications consisting of Java Servlets, JavaServer pages, Enterprise JavaBeans, and Web Services. Part I of this book provides a general introduction to JRun and J2EE. Part II contains tutorials to show you how to build a simple J2EE application. In the tutorial lessons, you add a JRun server and write the code for servlets, JSPs, JavaBeans, and EJBs.
This preface tells you how to access JRun and Macromedia resources, such as websites, documentation, and technical support.
Contents
Developer resources.............................................................................................. viii
About JRun documentation.................................................................................... ix
Other resources........................................................................................................ x
Contacting Macromedia........................................................................................xiv
vii
Developer resources
Macromedia, Inc. is committed to setting the standard for customer support in developer education, documentation, technical support, and professional services. The Macromedia website is designed to give you quick access to the entire range of online resources. The following table shows the locations of these resources.
Resource Description
Information on JRun
http://www.macromedia.com/products/jrun /http://www.macromedia.com/products/
jrun//a
JRun Online Forum
http://webforums.macromedia.com/jrunhtt
p://webforums.macromedia.com/jrun/a
Developer Resources
http://www.macromedia.com/desdev/devel oper/http://www.macromedia.com/desdev/
developer//a
JRun Support Center
http://www.macromedia.com/support/jrunh
ttp://www.macromedia.com/
support/jrun/a
Tr a i n i n g
http://www.macromedia.com/support/traini ng/http://www.macromedia.com/support/
training//a
Detailed product information on JRun and related topics.
Access to experienced JRun developers through participation in the Macromedia Online Forums, where you can post messages and read replies on many subjects relating to JRun.
All of the resources that you need to stay on the cutting edge of JRun development, including online discussion groups, Component Exchange, Resource Library, technical papers, and more.
Professional support programs that Macromedia offers.
Information about classes, on-site training, and online courses offered by Macromedia.
Macromedia Alliance
http://www.macromedia.com/partners/http
://www.macromedia.com/partners//a
viii About This Book
Connection with the growing network of solution providers, application developers, resellers, and hosting services creating solutions with JRun.
About JRun documentation
JRun documentation provides support for all JRun users, including JSP developers, servlet developers, EJB client developers, EJB bean developers, and system administrators. The printed and online versions are organized to let you quickly locate the information that you need. JRun online documentation is provided in HTML and Adobe Acrobat formats.
Printed and online documentation set
The JRun documentation set consists of the following titles:
Book Description
Installing JRun Describes installing and configuring JRun.
Getting Started with JRun Provides a J2EE overview, concepts, and tutorials for
JSPs, servlets, EJBs, and web services.
JRun Administrator’s Guide Describes how to integrate a JRun server into an
existing environment.
JRun Programmer’s Guide Describes how to use JRun to develop JSPs, servlets,
custom tags, EJBs, and web services.
JRun Assembly and Deployment Guide
JRun SDK Guide Provides information to OEM/ISV customers and
JRun Quick Reference Provides brief descriptions and syntax for JavaServer
Online Help Provides JMC users with usage notes, procedures, and
Accessing online documentation
All JRun documentation is available online in HTML and Adobe Acrobat formats. To access the documentation, open the following file on the server running JRun:
jrun_root/docs/dochome.htm. JRun_root is the directory into which you installed JRun.
Macromedia provides online versions of all JRun books as Adobe Acrobat Portable Document Format (PDF) files. The PDF files are included on the JRun CD and installed in the JRun /docs directory, although they are an optional part of the installation. You can access them by clicking the Product Documentation link on the JRun Management Console Welcome window.
Describes how to assemble and deploy the components of a J2EE application.
advanced users who embed, customize, or use the APIs in JRun.
Pages (JSP) directives, actions, and scripting elements.
concepts.
About JRun documentation ix
Other resources
You can consult the following resources for more information on topics described in JRun documentation.
Books
Servlets, JavaServer Pages, and Tag Libraries
JRun Web Application Construction Kit
Java Server Pages Application Development
http://www.moreservlets.comMore
Servlets and JavaServer Pages/a
http://www.coreservlets.comCore
Servlets and JavaServer Pages/a
Java Servlet Programming, Second
Edition
http://www.servletguru.comJava
Servlets Developer’s Guide/a
Drew Falkman Macromedia Press, 2001 ISBN: 0789726009
Scott M. Stirling, et al. Sams, 2000 ISBN: 067231939X
Marty Hall Prentice Hall PTR, 2001 ISBN: 0130676144
Marty Hall Prentice Hall PTR, 2000 ISBN: 0130893404
Jason Hunter and William Crawford O'Reilly & Associates, 2001 ISBN: 0596000405
Karl Moss McGraw-Hill/Osborne Media, 2002 ISBN: 0-07-222262-X
http://www.sourcestream.comInside
Servlets: Server-Side Programming for the Java Platform, Second
Edition/a
Web Development with JavaServer Pages
Enterprise Java Servlets Jeff Genender
Advanced JavaServer Pages David Geary
x About This Book
Dustin R. Callaway Addison-Wesley, 2001 ISBN: 0201709066
Duane K. Fields and Mark A. Kolb Manning Publications Company, 2000 ISBN: 1884777996
Addison-Wesley, 2001 ISBN: 020170921X
Prentice Hall, 2001 ISBN: 0130307041
JavaServer Pages Hans Bergsten
O’Reilly & Associates, 2000 ISBN: 156592746X
JSP Tag Libraries Gal Schachor, Adam Chace, and Magnus Rydin
Manning Publications Company, 2001 ISBN: 193011009X
Core JSP Damon Hougland and Aaron Tavistock
Prentice Hall, 2000 ISBN: 0130882488
JSP: Javaserver Pages (Developer’s Guide)
Barry Burd Hungry Minds Inc., 2001 ISBN: 0764535358
Enterprise JavaBeans
http://www.middleware-company.c omMastering Enterprise JavaBeans,
Second Edition/a
Ed Roman John Wiley & Sons, 2002 ISBN: 0471417114
Enterprise JavaBeans, Third Edition Richard Monson-Haefel
O'Reilly & Associates, 2001 ISBN: 0596002262.
Professional EJB Rahim Adatia, et al
Wrox Press, 2001 ISBN: 1861005083
Special Edition Using Enterprise JavaBeans (EJB) 2.0
Chuck Cavaness and Brian Keeton Que, 2001 ISBN: 0789725673
Applying Enterprise JavaBeans: Component-Based Development for the J2EE Platform
Vlada Matena and Beth Stearns Addison-Wesley Pub Co, 2000 ISBN: 0201702673
Enterprise Java Programming
Professional Java Server Programming J2EE 1.3 Edition
Server-Based Java Programming Te d N ew ar d
Subrahmanyam Allamaraju, et al Wrox Press, 2001 ISBN: 1861005377
Manning Publications Company, 2000 ISBN: 1884777716
Other resources xi
Designing Enterprise Applications with the Java 2 Platform, Enterprise Edition
Nicholas Kassem Addison-Wesley, 2000 ISBN: 0201702770 (free download at
http://java.sun.com/j2ee/download.html#blueprintsh
ttp://java.sun.com/j2ee/download.html#blueprints/a )
Building Java Enterprise Systems with J2EE
J2EE: A Bird's Eye View (e-book) Rick Grehan
Java Message Service Richard Monson-Haefel and David Chappell
J2EE Connector Architecture and Enterprise Application Integration
Building Web Services with Java: Making Sense of XML, SOAP, WSDL and UDDI
Architecting Web Services William L. Oellermann Jr.
Paul Perrone and Venkata S.R. “Krishna” .R. Chaganti
Sams, 2000 ISBN: 0672317958
Fawcette Technical Publications, 2001 ISBN: B00005BAZV
O’Reilly and Associates, 2001 ISBN: 0596000685
Rahul Sharma, et al Addison-Wesley, 2001 ISBN: 0201775808
Sim Simeonov, Glen Daniels, et al Prentice Hall, 2002 ISBN: 0672321815
Apress, 2001 ISBN: 1893115585
Online resources
Java Servlet API http://java.sun.com/products/servlethttp://java.sun.co
JavaServer Pages API http://java.sun.com/products/jsphttp://java.sun.com/p
Enterprise JavaBeans API http://java.sun.com/products/ejb/http://java.sun.com/
Java 2 Standard Edition API http://java.sun.com/j2se/http://java.sun.com/j2se//a
Servlet Source http://www.servletsource.comhttp://www.servletsourc
JSP Resource Index http://www.jspin.comhttp://www.jspin.com/a
xii About This Book
m/products/servlet/a
roducts/jsp/a
products/ejb//a
e.com/a
Server Side http://www.theserverside.comhttp://www.theserversid
e.com/a
Dot Com Builder http://dcb.sun.comhttp://dcb.sun.com/a
Servlet Forum http://www.servletforum.com/http://www.servletforum
.com/a
Other resources xiii
Contacting Macromedia
Corporate headquarters
Technical support Macromedia offers a range of telephone and web-based
Sales Toll Free: 888.939.2545
Macromedia, Inc. 600 Townsend Street San Francisco, CA 94103
Tel: 415.252.2000 Fax: 415.626.0554
http://www.macromedia.com www.macromedia.com/a
Web:
support options. Go to
http://www.macromedia.com/support/http://www.macromedia
.com/support//a for a complete description of technical support services.
You can make postings to the JRun Support Forum (http://webforums.macromedia.comhttp://webforums.macrom edia.com/a) at any time.
Te l: 61 7. 21 9. 2 1 00 Fax: 617.219.2101
E-mail:
mailto:sales@macromedia.comsales@macromedia.com/a
Web:
http://www.macromedia.com/store/http://www.macromedia.c
om/store//a
OEM/hosting sales For information about OEM/hosting, such as inquiries
regarding licensing and pricing for product, support, training and consulting, contact:
Toll Free: 888.939.2545, request OEM Sales Desk extension
2157. OEM Sales Desk: 617.219.2157 Fax: 617.219.2102 E-mail:
mailto:oemsales@macromedia.comoemsales@macromedia.c
om/a Web:
http://www.macromedia.com/software/jrun/oemhttp://www.m
acromedia.com/software/jrun/oem/a
xiv About This Book
PART I
Introduction
This part contains an introduction to JRun and J2EE.
Welcome to JRun..........................................................................................................3
JRun Programming Model........................................................................................15
Introduction to J2EE..................................................................................................29
Using Servlets and JSP............................................................................................ 37
Introduction to EJB .....................................................................................................47
Developing Web Applications ................................................................................55
CHAPTER 1
Welcome to JRun
This chapter contains an overview of Macromedia JRun and JRun architecture. It describes many of the features and tools that you use during application development and deployment. It also includes a description of different types of JRun users and pointers to the JRun documentation where each type of user can find additional information.
Contents
About JRun............................................................................................................. 4
J2EE standards compliance......................................................................................6
JRun architectural model......................................................................................... 7
JRun features........................................................................................................... 8
Development tools................................................................................................. 13
What to do next .................................................................................................... 14
3
About JRun
JRun is a complete Java application server for developing and deploying reliable, scalable, and secure server-side Java 2 Enterprise Edition (J2EE) applications. JRun supports the latest industry standards for developing applications composed of Java Servlets, JavaServer pages (JSP), Enterprise JavaBeans (EJB), Java Message Service (JMS), Macromedia Flash files, HTML pages, images, and other resources.
JRun supports a variety of Windows and UNIX platforms. Its open design lets JRun work with a variety of existing web servers, including Apache, Microsoft Internet Information Server (IIS), Netscape Enterprise Server (NES), Netscape iPlanet, and Zeus. With JRun, you can deploy websites with dynamically generated content on almost any platform.
JRun connects to a web server using a plug-in mechanism unique to each web server: Netscape Server API (NSAPI) for Netscape, Internet Server API (ISAPI) for Microsoft IIS, and the Apache 1.3 and 2.0 Dynamic Shared Object (DSO) interfaces for the Apache web server. However, you do not need to have a separate web server to develop and deploy applications using JRun. JRun provides its own built-in web server.
For more information, see Installing JRun.
Benefits of server-side Java
Java Servlets, JSPs, and EJBs are all examples of server-side Java—that is, Java code that executes on an application server rather than on a web client.
Server-side Java has many important features that make it extremely useful for developing web server applications, including the following:
Consistent Java features You can guarantee that your server supports the features
of Java that are required by your application.
Up-to-date Java technologies As the Java standard continues to evolve, your
server-side application can immediately take advantage of new Java features, regardless of the compliance level of clients.
Control over the Java Virtual Machine (JVM) Your server runs the JVM that you
require for your application.
Server-side Java lets you completely realize the Java “write once, run anywhere” goal. The full capabilities of the language are available to you with no limitations or restrictions. Because these applications run on the server, you can also control the platform, the operating system, and every aspect of the environment in which your application runs.
With complete control over your environment, you can develop on one platform and deploy on another with confidence that your application will run properly on both platforms.
4 Chapter 1 Welcome to JRun
Benefits of using J2EE
The J2EE platform represents a single standard for implementing and deploying multitier, enterprise applications. J2EE applications take advantage of Java’s inherent portability and can be run on all platforms supported by JRun.
J2EE offers a number of benefits for application programmers, including the following:
Rich set of standard APIs and services
High performance
Integration with backend infrastructure, such as Relational Database Management
Systems (RDBMS) and Enterprise Information Systems (EIS)
Industry support, including third party tools and Application Programming
Interfaces (APIs)
JRun is standardized on the latest J2EE platform specifications, highlighted in the following section.
About JRun 5
J2EE standards compliance
Macromedia JRun is a J2EE-compliant application server. JRun passed the J2EE Compatibility Test Suite (CTS) and delivers the full capabilities of the most recent Sun J2EE 1.3 platform specification. The following table describes the many enhancements and new features in the 1.3 specification:
Feature Description
EJB 2.0 Provides enhancements that simplify the development of distributed
components.
Container Managed Persistence (CMP) 2.0 lets developers build
portable applications that are database-independent and free of database access code.
Introduces a standard, database-independent EJB query language
(EJBQL).
Introduces local interfaces to efficiently invoke an EJB component
residing on the same computer as the calling application.
Message Driven Beans (MDB)
J2EE Connector Architecture (JCA) 1.0
JSP 1.2 Supports several additions to the JSP API, including the following:
A part of the EJB 2.0 specification, combines the asynchronous benefits of the Java Message Service (JMS) with EJB. MDBs are message listeners that run in the EJB container and can use container services, such as security and transactions.
Defines a standard architecture that supports integration of J2EE servers with enterprise information systems, such as Enterprise Resource Planning (ERP) systems, mainframe transaction processing systems, and legacy database systems.
Two new tag types, IterationTag and TryCatchFinallyTag.
An XML syntax for JSP pages (JSPX), which makes it easier to
automate the authoring of JSP pages.
A number of enhancements to Tag Library Descriptors (TLD) that
improve portability, and better support authoring tools.
Servlet 2.3 Introduces the following two important new features:
Application events Useful for application initialization code and
can replace preloaded servlets in some cases.
Filters Allow pre- and post-processing of servlet requests.
Java APIs for XML Processing (JAXP) 1.1
Supports the latest XML development features, including a pluggable architecture for adding your choice of XML parser or XSL processor into the server and overriding the default components that JRun includes.
Java Message Service (JMS) 1.0
Java Authentication and Authorization Service (JAAS)
6 Chapter 1 Welcome to JRun
Lets J2EE application components create, send, receive, and read messages. It enables distributed communication that is loosely coupled, reliable, and asynchronous.
Provides a way for a J2EE application to authenticate users and enforce access controls in a modular fashion.
For detailed information on the J2EE platform, see Chapter 3, “Introduction to J2EE”
on page 29.
JRun architectural model
JRun has a service-based architecture, a modular design that contains pluggable services (components) in a core server backbone.
The server backbone facilitates communication among all components or services that plug into it. It provides a core set of services that are shared across all the components and features of the server. The backbone provides flexibility through its ability to accommodate various services. Services extend the core server by adding functionality, independently of each other.
In JRun, the core server backbone is the server kernel. The services are JRun server features, as the following figure shows:
The JRun architecture is based on Java standards, including the following:
Java Management Extensions (JMX) Specifications for managing Java
environments. JMX defines the architecture and APIs for a scalable system that you can integrate with existing management systems.
Java Naming & Directory Interface (JNDI) A standard mechanism for Java-based
applications to access application components and server resources across a distributed computing environment.
XML An open, cross-platform formatting standard used for storing information
about the state of a JRun service.
JRun is built on a JMX service-based architecture, and uses JMX to provide flexible and dynamic management and administration. JMX is an emerging Java standard for management and customization.
JRun implements its features and functionality (for example, EJB container, web container, and logging) as JMX services (called MBeans), plugged into the JRun kernel. You can manage these services through the JMX-enabled JRun Management Console (JMC) or other JMX-enabled management tools.
JRun architectural model 7
Because services are independent of each other and can be restarted individually, the JRun service-based architecture ensures high application availability. It also provides a highly customizable and easily extensible platform. You can unplug unneeded services to avoid the overhead of unused functionality. Administrators, advanced developers, and Original Equipment Manufacturers (OEMs) can also create their own custom services (MBeans) and plug them into the JRun kernel. All JRun services can take advantage of the clustering capabilities built into the JRun kernel.
For more information on JRun architecture, see JRun Administrator’s Guide.
JRun features
JRun 4 provides many new and changed features, including the following:
Dynamic deployment of J2EE components
Dynamic servlet and class reloading and compilation
Dynamic creation of database tables for entity beans
JRun Server Tags (JST)
JRun Management Console (JMC)
Web Server Configuration tool
Clustering
Security
Enterprise Deployment Wizard
XDoclet integration
Pointbase database server
JDBC Drivers
Sample applications
Web services
Dynamic deployment of J2EE components
JRun provides auto deploy and hot deploy features for dynamic deployment of web applications, EJBs, enterprise applications, and enterprise resource adapters from Java archive files or expanded directories. When you copy a J2EE module archive file or directory to a deploy directory (jrun_root/servers/jrun_server, by default), JRun automatically deploys the module in a running server or deploys it the next time the server starts. The deployment is dynamically updated when you modify a module archive file or deployment descriptor. For more information, see JRun Assembly and Deployment Guide.
Dynamic servlet and class reloading and compilation
You can configure JRun to dynamically recompile and reload servlets, JSPs, servlet helper classes, and JSP helper classes when a servlet or JSP is called. When the compile and reload features are enabled, JRun dynamically recompiles and reloads a servlet when it is called. JRun also dynamically recompiles and reloads classes in the WEB-INF/classes directory, and tag library classes when they are called by a servlet or JSP. This feature is disabled by default.
8 Chapter 1 Welcome to JRun
You enable dynamic compiling and reloading by creating a WEB-INF/jrun-web.xml file that contains the following text, setting the reload and compile values to false or true:
<jrun-web-app> <reload>true</reload> <compile>true</compile> </jrun-web-app>
For more information, see JRun Assembly and Deployment Guide.
Dynamic creation of database tables for entity beans
When you deploy an entity bean, and its required database tables do not yet exist, JRun can generate them for you when you have configured the appropriate Java Database Connectivity (JDBC) data source in JRun. For more information, see JRun Programmer’s Guide.
JRun Server Tags (JST)
JST technology supports JSP 1.2 and recursion. JST lets you write custom JSP tags using JSP syntax, rather than the custom tag handler API. Recursion allows a JST to call itself.
JRun Management Console (JMC)
The redesigned, JMX-enabled JMC provides an easy-to-use, intuitive graphical user interface for managing your local and remote JRun servers. Using the JMC, you can create servers, define clusters, manage applications, and implement security based on JAAS. For additional information, see the JMC online Help.
Web Server Configuration tool
JRun provides native connectors for most major web servers. Using the Web Server Configuration tool, you can connect one or more web servers to each JRun server. The Web Server Configuration tool, a stand-alone tool, does not require JRun on the web server host. For information on connecting JRun to an external web server, see Installing
JRun. For more information on understanding web server connectors, see JRun Administrator’s Guide.
Clustering
JRun provides enterprise-level server clustering for maximum reliability and scalability. Clustering is built into the web server connectors and the JRun kernel:
At the web server connector level, clustering enables load balancing and automatic
failover between the web server and the web containers. In-memory session replication ensures that state information is preserved if the web server fails over to another web container in the cluster.
At the kernel level, clustering enables load balancing and automatic failover for
clusterable server objects, such as EJBs, JNDI trees, or any clusterable custom service. The object state (for example, the state of a stateful EJB) is automatically replicated in an optimized manner to provide the highest level of reliability while maintaining performance. JRun servers use the JINI technology to dynamically locate their peers
JRun features 9
Security
in the cluster, eliminating the risk inherent to a single point of failure. For more information, see JRun Administrator’s Guide.
JRun supports the JAAS 1.0 specification, which includes the following levels of security:
JRun administration security JRun uses JAAS as the security framework. JAAS is
a set of packages that lets JRun authenticate users and enforce access controls in a modular fashion. The default JAAS security module provides an XML-based security management (jrun-users.xml). JAAS provides a pluggable mechanism that lets you customize the system to integrate with existing authentication user stores, such as LDAP or a relational database. In addition, you can write custom security modules based on the JAAS specification.
JRun includes a JDBC-based login module and an LDAP-based login module, which perform authentication and authorization using information stored in a relational database or an LDAP directory. JRun also supplies a login module for users and groups from Windows domains. For more information, see JRun Administrator’s Guide or the JMC online Help.
Web application security To address security issues that involve web applications,
the Java Servlet API specification defines an authentication mechanism to control client access to resources within a web application. Web application security guarantees that only authorized web clients have access to the resources on a website. For more information on web application security, see JRun Administrator’s Guide.
EJB security JRun provides a configurable mechanism for implementing EJB
security, as defined in the EJB specification. In the deployment descriptor, you specify the users or roles allowed to access each bean method. You can specify the type and content of user information to be verified, what composes a role, and how authentication occurs. This flexibility can accommodate security schemes that you might already have in place. For more information on EJB security, see JRun Administrator’s Guide.
Enterprise Deployment Wizard
JRun includes the Enterprise Deployment Wizard for developing, packaging, and deploying EJBs. Using its Swing-based graphical user interface, you can create any type of EJB, or edit the deployment descriptor of existing EJBs, package them into JAR files, and deploy them on JRun. In particular, the object-relational mapping capabilities of the Enterprise Deployment Wizard let you streamline the entity bean development process.
The Enterprise Deployment Wizard runs as a stand-alone tool, or as a plug-in on top of an Java Integrated Development Environment (IDE).
To start the Enterprise Deployment Wizard, run jrun_root/bin/jrunwizard.exe (Windows) or jrun_root/bin/jrunwizard (UNIX).
To install the Enterprise Deployment Wizard in an IDE, open a console window to the jrun_root/lib directory and issue the following command:
java -jar jrunwizard-installer.jar
For a list of currently supported IDEs, see the Release Notes.
10 Chapter 1 Welcome to JRun
The Enterprise Deployment Wizard features a context-sensitive online Help system. For usage information, see the online Help.
XDoclet integration
JRun provides integration with XDoclet, a popular open-source Java utility that greatly simplifies the development of J2EE modules (such as EJBs, servlets, and custom tags) by letting you maintain your component metadata using Javadoc-style tags in a single source file.
For example, to create an EJB, you traditionally have to maintain four different files: the home interface, the remote or local interface, the implementation class, and the deployment descriptor. Using XDoclet, you only maintain a single source file (the implementation class) that you annotate with special Javadoc tags, that indicate how the auxiliary files should be built. JRun senses modifications to the source file and automatically builds the auxiliary files (such as interfaces and deployment descriptors). For more information, see JRun Programmer’s Guide.
Pointbase database server
JRun includes a restricted version of the PointBase Server Database Management Software (DBMS). This is an all-Java database used with the JRun sample applications. You can use this database server for your evaluation and development work. For more information on the PointBase database, see the PointBase documentation, located in jrun_root/pointbase/docs. (jrun_root is the directory into which you installed JRun.)
JDBC Drivers
JRun embeds type 4 JDBC database drivers that provide connectivity to all major databases.
Sample applications
The samples JRun server contains a variety of applications that illustrate a number of coding techniques. The following table describes the samples applications that are included with JRun:
Application Description
Compass travel A simple online travel agent trip reservation system. This
TravelNet An online travel agent that sells trips from Compass travel. This
application illustrates JSP, servlet, and EJB programming and is delivered as an enterprise application in an open-directory structure. Compass travel uses the compass database, accessing it through the compass data source, which you can view through the JMC. For companion tutorial lessons, see Part II, Tutorials.
application illustrates JSP and web services programming, and is delivered as an enterprise application in an open-directory structure. For companion tutorial lessons, see Lesson 4, “Web
Services Tutorial” on page 97.
JRun features 11
Application Description
World music An e-commerce application that sells music. This application also
contains an admin module. The world music application illustrates many common design patterns using JSP, servlet, and JavaBean programming. The world music sample application uses the worldmusic database, accessing it directly through JDBC.
Web services Programming techniques used in JRun web services
programming.
Web services
Programming techniques
Flash gateway Flash movies and Flash Gateway adapters, which illustrate how to
SmarTicket A Java Blueprints J2ME application. The SmarTicket application
Java PetStore A Java Blueprints J2EE application that shows how to use the
Programming techniques described in this book. The techniques application uses the samples database, accessing it through the samples data source, which you can view through the JMC.
write Flash applications that communicate with JRun.
illustrates how the J2EE platform interoperates with the Java 2 Micro Edition (J2ME) platform to create enterprise applications that serve mobile client devices, such as cell phones, two-way pagers, and palmtops.
The SmarTicket application uses the smarticket database, accessing it through the smarticket data source, which you can view through the JMC.
capabilities of the J2EE 1.3 platform to develop a typical e-commerce application, which can take and process orders and credit card information, manage user logins, shipping information, and shopping cart sessions.
JRun lets you publish and consume web services. Web services provide platform- and location-independent computing using XML and standard Internet protocols such as HTTP. By allowing previously incompatible applications to interoperate over the web, regardless of language, platform, or operating system, web services create new business opportunities and help companies adapt to changing business relationships. For example, a Microsoft .NET component can communicate with a J2EE component, such as an Enterprise JavaBean (EJB).
Using JRun, you can reuse existing Java code as a web service, or write new code specifically to publish as a web service. You also can create object- and tag-based clients that can invoke methods on remote web services, even when those services reside on non-Java platforms.
The JRun web services implementation is built on Apache Axis, the third generation of the Apache Software Foundation’s Simple Object Access Protocol (SOAP) engine. For more information, see JRun Programmer’s Guide.
For more information on JRun 4 features, see the Release Notes in jrun_root/ relnotes.htm.
12 Chapter 1 Welcome to JRun
Development tools
Macromedia provides development tools (available separately) to work with JRun. Additionally, you can use JRun with your Java IDE.
Dreamweaver MX
Dreamweaver MX is an HTML editor for visually designing and managing websites and JSPs created with JRun. Dreamweaver MX increases JSP developer productivity with the following coding tools and features:
Visual programming Accelerate development with powerful two-way visual
programming tools integrated with transparent source editing.
HTML design Includes all the functionality of Macromedia HomeSite, the
award-winning HTML design tool.
JavaScript Debugger
Code editors Code view and Code inspector that let you edit JavaScript, XML,
and other text documents.
Using JRun with your Java IDE
You can fully integrate JRun with your Java IDE. When setting up your IDE to work with JRun, you specify the following:
The class containing the JRun server main method: jrunx.kernel.JRun, contained
in jrun_root/lib/jrun.jar
Note: The jrun_root directory is the directory into which you installed JRun.
The working directory: jrun_root/bin
The JAR files needed in the JRun runtime classpath: All the JAR files located in
jrun_root/lib and jrun_root/servers/lib
Note: The JRun JDBC drivers are included in the jrun_root/lib/jrun.jar file and require no special attention.
The command-line arguments passed to the JRun server main method:
start [jrun_server]
Note: Before starting JRun inside your IDE, stop the JRun server on your computer. Otherwise, port conflicts arise with the running server, and JRun will not start inside your IDE.
Installing the Enterprise Deployment Wizard in your Java IDE
To install the Enterprise Deployment Wizard in an IDE, open a console window to the jrun_root/lib directory and issue the following command:
java -jar jrunwizard-installer.jar
For a list of currently supported IDEs, see the Release Notes. The Enterprise Deployment Wizard features a context-sensitive online Help system. For
usage information, see the online Help.
Development tools 13
What to do next
The remaining chapters in Part I provide a general introduction to JRun and J2EE. These chapters include the following:
Chapter 2, “JRun Programming Model” on page 15
Chapter 3, “Introduction to J2EE” on page 29
Chapter 4, “Using Servlets and JSP” on page 37
Chapter 5, “Introduction to EJB” on page 47
Chapter 6, “Developing Web Applications” on page 55
All JRun users should be familiar with the information in these chapters. Part II contains tutorials to show you how to build a simple J2EE application. In the
tutorial lessons, you add a JRun server and write the code for servlets, JSPs, JavaBeans, and EJBs. You learn how to combine these elements to produce a flexible and scalable J2EE application. In the last tutorial lesson, you use web services to access data in a JRun sample application.
The following table shows the books to read after the introductory chapters, depending on your role in developing and deploying JRun applications:
Role Description For more information
All JRun developers Performs common development tasks
including application monitoring, debugging, and authentication.
System administrator Responsible for installing and
administrating JRun in a production environment, starting and stopping JRun, and adding and removing applications.
JSP developer Creates JSPs that generate dynamic
content that is returned to clients. These JSPs can reference Java Servlets, custom tag libraries, or JavaBeans.
Java Servlet and tag library developer
EJB developer Creates reusable components used by
Application deployer Packages JRun applications for
Develops servlets in Java, and also develops custom tag libraries used in JSPs.
Java Servlet and JSP developers.
deployment or resale.
JRun Administrator’s Guide
JRun Administrator’s Guide
JRun Programmer’s Guide
JRun Programmer’s Guide
JRun Programmer’s Guide
JRun Assembly and Deployment Guide
14 Chapter 1 Welcome to JRun
CHAPTER 2
JRun Programming Model
JRun is a complete Java application server for developing and deploying J2EE enterprise applications. This chapter describes the JRun programming model, the major components of JRun, and JRun support for J2EE enterprise applications.
Contents
Enterprise application architecture......................................................................... 16
JRun programming environment........................................................................... 19
JRun servers........................................................................................................... 20
Web servers............................................................................................................ 25
JRun support for J2EE applications ....................................................................... 26
15
Enterprise application architecture
The standards for enterprise application development on the web are based on the J2EE specification. JRun supports the J2EE application model and provides a runtime environment for executing enterprise applications.
Enterprise application design
Enterprise applications share several common design goals, including the following:
Extensibility and maintainability It should be easy to add and maintain new
functionality.
Scalability, portability, and availability Many enterprise applications must scale to
support thousands of users. A portable application reduces the risk of vendor lock-in and system obsolescence. High availability ensures uninterrupted access to enterprise data and business functions.
Code reuse Code developed for an application must be reusable within the
application and, ideally, in other applications as well.
Interoperability An enterprise application must be able to interoperate with other
systems, using their services and providing services to them, particularly existing information assets, including legacy systems.
Focus on implementing business logic Developers must focus on writing code to
address business issues and minimize time spent dealing with system mechanisms.
For more information on application design patterns, see JRun Programmer’s Guide. Dividing an enterprise application into tiers supports an enterprise application’s design
goals with layers that separate differing design and implementation concerns, such as information persistence, application functionality, and user interaction. The next section explains the roles of the tiers in a J2EE application and describes the technologies available in each tier.
For more information on J2EE, see Chapter 3, “Introduction to J2EE” on page 29.
J2EE application architecture
By definition, J2EE applications are multitiered. Each tier brings specific benefits to the application design. A tiered architecture provides natural access points for integration with existing and future systems. J2EE applications divide their functionality across several tiers or functional layers, each of which serves a specific purpose. This model divides the functionality of a business website into discrete components that can be implemented independently from each other. Typically, multitier applications have the following characteristics:
Client tier User interaction and data capture occur in the client tier. Client tier
programs translate user actions and input into server requests, and format server responses; for example, using a browser to access the middle tier over an HTTP connection, such as the Internet. Included in this tier are any applets that execute on the client’s machine.
16 Chapter 2 JRun Programming Model
Loading...
+ 102 hidden pages