Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your profile (name, country/region, and company) is displayed to the public and will accompany any content you post. You may update your IBM account at any time.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

developerWorks Community:

  • Close [x]

Generating Java using EGL and JSF with WebSphere Studio Site Developer V5.1.2

Reginaldo Barosa (rbarosa@us.ibm.com), Certified IT Specialist, IBM, Software Group
Photo of Reginaldo Barosa
Reginaldo W. Barosa is an IBM Certified Application Development Specialist. He provides sales support, helping customers with enterprise transformation solutions and development tools, such as WebSphere Developer for System z. Before joining IBM US, Reginaldo worked for 27 years in IBM Brazil. He has co-authored IBM Redbooks and has written books, as well as other articles for IBM developerWorks. He holds a degree in Electrical Engineering from Instituto Mau de Tecnologia, Sao Paulo, Brazil.

Summary:  This article describes how to use JSF and WebSphere Studio Site Developer V5.1.2 to deploy EGL applications to WebSphere Application Server V5.1. It shows you how to code, test, generate, and deploy a three-tier application consisting of a Web interface, WebSphere Application Server, and a server program that accesses DB2.

Date:  01 Aug 2004
Level:  Intermediate

Activity:  9146 views
Comments:  

Introduction

This tutorial describes the architecture that IBM® WebSphere® Studio V5.1.2 uses to deploy Enterprise Generation Language (EGL) applications to WebSphere Application Server V5.1 using JavaServer Faces (JSF) technology. It will describe in detail how to code, test, generate, and deploy a three-tier application consisting of a Web interface, business logic that executes on WebSphere Application Server, and a server program that performs a DB2® query to access a database.

We will implement a simple program using EGL and JSF. The EGL and JSF architecture is an event-driven model in which each request is handled by a specific page handler. The page handler can act on information submitted with the request, or forward it to another handler for processing. This event-driven model greatly simplifies the building of Web applications. We will use EGL to implement this model, which means you won't need Java™ skills, since all of the Java code will be generated from the EGL code.

This tutorial will not focus on the actual coding of the program and the power of the EGL language. Instead, it will describe the production process of coding, generating and testing using either WebSphere Studio Application Developer V5.1.2 or WebSphere Studio Site Developer V5.1.2 (hereafter both called "Studio") to deploy to WebSphere Application Server V5.1 (hereafter called "Application Server"). The article will also show how to implement a called server program that runs apart from the application server as a remote server using TCP/IP as the communications protocol.

When you see the symbol , double-click on it, and an animation sequence will demonstrate a specific development task.

If you wish, you can download the sample program below and load it into WebSphere Studio instead of starting from scratch. The download file EGL_JSF.zip contains three files:

EGL_JSF_BAROSA_SOURCE_CODE.zip
Source code to be imported to Studio
EGL_DEMO_EAR.ear
EAR file ready to be deployed to WebSphere Application Server
EGLDemoServer.jar
Server code to be deployed to server machine

To install the source code, import EGL_JSF_BAROSA_SOURCE_CODE.zip to your workspace using the Import Project Interchange wizard. Then modify the file vgj.properties to add your user ID and password for the database connection.

What is EGL?

EGL is a development environment and programming language that lets you write full-function applications quickly. It frees you to focus on the business problem your code is addressing rather than on software technologies. You can use similar I/O statements to access different types of external data stores, whether those data stores are files, relational databases, or message queues. Also, the details of Java and J2EE are hidden from you, so you can deliver enterprise data to browsers even if you have minimal experience with Web technologies. After you code an EGL program, you generate it to create Java source code. Then EGL prepares the output to produce executable objects. EGL also can provide these services:

  • Placing the source on a deployment platform separate from the development platform
  • Preparing the source on the deployment platform
  • Sending status information from the deployment platform to the development platform, so you can check the results
  • Producing output that facilitates the final deployment of the executable objects

An EGL program written for one target platform can be easily ported to another, which means that you can code in response to current platform requirements, and migrate in the future without bothering about migration details. EGL can also produce multiple parts of an application system from the same source.

To access EGL applications from a Web Browser, you can create a J2EE Web application.The different records and functions defined with EGL are generated as Java code and displayed using JavaServer Faces (JSF) technology.

What is JSF?

JSF is a set of Java classes and JSP tag libraries that provide a framework for developing Web applications. You can use JSF to help you develop applications that are divided into three functional layers:

Model
The business logic, which in most cases involves accessing data stores such as relational databases. The development team that handles the model may be expert at writing DB2 COBOL programs or some other technology appropriate for storing and manipulating enterprise data.
View
The code responsible for the presentation layer. The code consists of JSPs and Java beans that store data for use by the JSPs.
Controller
The code that determines the overall flow of events.

The model-view-controller framework (referred to as MVC or "model 2") has many benefits and is often considered a best practice for developing Web applications.

Solution architecture using JSF and EGL

Studio uses the JSF architecture shown in Figure 1. At run time, Application Server contains both the view and controller components of an MVC Web application, while a third tier (which can be inside or outside of Application Server) contains the model.


Figure 1. JSF and EGL architecture
Figure 1. JSF and EGL architecture

Implementing a simple application using EGL

To better understand EGL, we will implement a very simple application using a Web browser. In this application:

  1. The user types an ID and clicks a button to invoke the server program, passing an working area.
  2. The server program reads a DB2 database using the ID as key.
  3. If the ID is found, the server program moves the Name, Salary and Commission to the working area and returns it.
  4. The returned data is sent to the Result JSP page and displayed.
  5. If the ID is not found, the server program moves an error message to the working area and returns it.
  6. The error message is sent to the Error JSP page and displayed.

Show me an animation of this application running under WebSphere Studio.

The database to be used is the SAMPLE database, and the table to be used is the STAFF table. The flow is shown in Figure 2:


Figure 2. Application flow
Figure 2. Application flow

The next steps will guide you through the creation, testing, and deployment of the application shown above. To complete this application you will need:

  • IBM WebSphere Studio Site Developer V5.1.2 or another WebSphere Studio product such as WebSphere Studio Application Developer V5.1.2.
  • IBM DB2 UDB V7 or later with the SAMPLE database created.
  • TCP/IP installed and configured. If you are not using a network, you will need to install the Microsoft® Loopback Adapter. For details, see the Windows® documentation. If you prefer, you can download the complete solution below.

This article is divided into four main sections:

  1. Section I. Build an EGL server program
  2. Section II. Build the client side of the application
  3. Section III. Generate the code and prepare the run-time environment under Studio
  4. Section IV. Deploy the client and the server application using WebSphere Application Server V5.1

Section I. Build an EGL server program

The EGL server program is the model component of the MVC model. Remember that the EGL server program will do a simple inquiry in the STAFF table (part of the SAMPLE database), and if the user ID is found the server program will get the name; if not, then a message will be moved to indicate an invalid user ID. If an error occurs connecting to the database, a message will be shown on another Web page. This is a very simple program but the idea is to just show how it can be implemented using EGL. In a real world the server program could be extremely complex, but in our example the Server has a very simple logic. Note that is not common to use a Server program just to do an database inquiry. The following tasks need to be performed to create the EGL server program in this example:

  1. Set preferences for SQL database connections
  2. Create a Studio project to work with EGL
  3. Create the EGL parts
  4. Debug/Run the EGL Server program

1. Set preferences for SQL database connections

Using Studio, prepare your workspace with the appropriate DB2 settings. This activity is usually done once, and is necessary since it provides the required defaults.

To set the EGL, select Windows => Preferences => EGL => SQL Database Connections. Our example will run under Windows. As shown in Figure 3 below, the following values are specified:

  • Connection URL: type the URL used to connect to the database through JDBC. For IBM DB2 APP DRIVER for Windows, the URL is jdbc:db2:dbName (where dbName is the database name. In our example jdbc:db2:SAMPLE
  • In the Database field, type the name of the database: SAMPLE
  • In the User ID field, type the user ID for the connection.
  • In the Password field, type the password for the user ID.
  • In the Database vendor type field, select the database product and version that you are using for your JDBC connection. We used DB2 V 8.1.
  • In the JDBC driver field, select the JDBC driver that you are using for your JDBC connection. We used IBM DB2 APP DRIVER
  • In the JDBC driver class field, type the driver class for the driver you selected. For IBM DB2 APP DRIVER for Windows, the driver class is COM.ibm.db2.jdbc.app.DB2Driver
  • In the class location field, type the fully qualified filename of the *.jar or *.zip file that contains the driver class. For IBM DB2 APP DRIVER for Windows, type the fully qualified filename to the db2java.zip file; in our example, C:\SQLLIB\java\db2java.zip.

(Most of these entries are already filled out, and don't need to be specified.)


Figure 3. Preferences for EGL Interpretive Debugger
Figure 3. Preferences for EGL Interpretive Debugger

2. Create a Studio project to work with EGL

A project is necessary to hold the resources and source files required for any application developed in Studio. EGL related projects will have some folders that are the roots for the EGL parts and its related Java generated code. An EGL project is created by selecting EGL or EGL Web as the project type when you create a new project. You assign properties while working through the steps of project creation. To begin modifying your choices after you have completed those steps, right-click the project name and when a context menu is displayed, click Properties. The instructions how to create the project will be explained in details below.

For our EGL Server program we do not need an EGL Web project. To set up a new EGL project: Using the Workbench:

  1. Click File => New => Project. The New Project wizard opens.
  2. In the left pane, click EGL. In the right pane, EGL Project.
  3. Click Next
  4. Type EGL_DEMO_Server as Project Name, select Java (since we will generate Java) and be sure that Create new project build descriptors) automatically is selected as shown in Figure 4
  5. Click Finish.

We will generate Java. This article does not cover COBOL generation, which requires another version of Studio -- WebSphere Studio Enterprise Developer V5.1.2.


Figure 4. Creating an EGL project
Figure 4. Creating an EGL project

If you are not at the EGL Perspective a message asking for a Perspective Switch will pop-up.

Click Yes to move to that perspective.

Please refer to the Studio documentation for better understanding the concept of perspectives. The folders JavaSource, EGLSource and Libraries will be created by the Studio wizard. The EGL components you will create in this tutorial must be under the folder EGLSource.

3. Create the EGL parts

An EGL file contains a set of parts, each of which is a unit of declaration in the overall declaration of the program, you declare parts in whatever order is convenient for you, and you name each one.

Currently parts are categorized as data, logic or build parts:

  • Data parts define the data structures that are available to your program. In some cases a data part includes a structure, which is a hierarchical layout of structure items that each define an area of memory. We can compare those parts as the data layouts that are part of a COBOL Data Division.
  • Logic parts define a run-time sequence that you write in the EGL procedural language. We can compare the logic parts as a COBOL Procedure Division. The logic parts can be:
    • A program part - defines the central logical unit at run time. We can compare a program as a Java Class or a COBOL or PL/I program. In our example we will create a called program named TE01A. (A called program is a basic program that has no interaction with the user can be invoked by any other program.) Programs are of the following types:
      • A basic program performs a task without interacting with the user during execution. It is like a batch or called COBOL program.
      • A textUI program interacts with the user via a character-based display (green screen). The display appears in a command window, not in a Web browser. It is like a COBOL program that has CICS BMS. We will not use textUI programs in this article, since our interface is the Web.
    • A function part -- is a logical unit that either contains the first code in the program or is invoked from another function. The function that contains the first code in the program is called main. A function it is similar to Java method or COBOL paragraphs.
    • A pageHandler part -- controls a user's run-time interaction with a Web page. Specifically, the page handler provides data and services to a JSP that displays the page. The page handler itself includes variables and event handlers each of which is invoked in response to a specific user action (specifically, by the user clicking a button or hypertext link). The pageHandler is generated automatically when we use the JSF/EGL wizards, but users will need to add its own EGL code to complement the logic, like navigation rules between pages.
    • A library part -- is a set of functions and variables and is generated and compiled independently of any program or page handler. The library resources can be made available in your program. It is recommended that you use libraries to maximize your reuse of common code and values. We will not use Library parts in our example since its optional. Please refer to the product documentation for better understanding of the library part.
  • Build parts define a variety of processing characteristics:
    • A build descriptor part controls the generation process and indicates what other control parts are read during that process. Those descriptors are created automatically when an EGL project is created. Each program must use one build descriptor that will tell how this program will be generated (for example, if Java or COBOL, etc...)
    • A linkage options part gives details on how a generated program transfers to other programs. The information in this part is used at generation time, test time, and run time. We will not use this part in our example since it is optional.
    • A resource associations part relates an EGL record with the information needed to access a file on a particular target platform; the information in this part is used at generation time, test time, and run time. Our example also will not use this part since it is optional and this program does not use sequential files.

Most programs will not require all parts explained above and also that some of those parts (like build descriptors) are typically created automatically by the Studio wizards.

3.1 Create the EGL Data parts.

It's a good practice to code an application from "back to front" -- with the "back" of an application being its data access and working areas, moving to the programmatic logic, and finally the user interface areas. Start defining first the database records, then the working areas (EGL Data parts), with the program logic (EGL Logic parts) coming later.

We will need to create two EGL Data parts, one that maps the DB2 Table (SQLRecord) and the other that will define a working area (basicRecord) to be passed between the Client (Web) and the Server Program.

To create the SQLRecord named TE01R01, follow these steps:

  1. Select the project EGL_DEMO_Server and in the workbench, click File => New => EGL Source File.
  2. Type a package name like demo.records, type TE01R01 as the name of the EGL file.
  3. Click Finish to create the file. See figure 5 below:
    Figure 5. Creating SQLRecord TE01R01
    Figure 5. Creating SQLRecord TE01R01
  4. An extension (.egl) is automatically appended to the end of the file name. The EGL file appears in the Project Navigator view and automatically opens in the default EGL editor. Use the Code Assist. Example type record and press Ctrl + Space and select record - SQL record with tablenames. Use STAFF as table name and T1 as tableLabel. Delete the items created as shown in Figure 6:
    Figure 6. Creating TE01R01 contents
    Figure 6. Creating TE01R01 contents
  5. Using the Outline view and the context editor select TE01R01 and click Retrieve SQL as shown in Figure 7 below (you can also use the context menu in the whitespace between the end curly brace for the table name and the end statement):
    Figure 7. Retrieve the DB2 record
    Figure 7. Retrieve the DB2 record

    Part of the results are shown in Figure 8 below. If you have problems accessing the database check the preferences done in the beginning of this article and be sure that the DB2 service is started:


    Figure 8. Getting the results
    Figure 8. Getting the results
  6. Move the mouse to TE01R01 in the editor and using the context menu select SQL Record > View Default Select. You should have the results shown below in Figure 9:
    Figure 9. Default Select statements for TE01R01
    Figure 9. Default Select statements for TE01R01
  7. Press Ctrl + S to save TE01R01 and close the editor:

    To create the working area named TE01W01, do similar steps as you did above:

  8. Select the project EGL_DEMO_Server and in the workbench, click File => New => EGL Source File.
  9. Use the same package created for the sqlRecord named demo.records
  10. Type TE01W01 as name of the EGL file
  11. Click Finish to create the file.
  12. Using the Code Assist create a basicRecord. Note that You can copy and paste the some item names and characteristics used in TE01R01. The record must be created as shown in Figure 10:
    Figure 10. TE01W01 working storage
    Figure 10. TE01W01 working storage
  13. Use Ctrl + S to save TE01W01and close the editor.

3.2 Create the EGL Logic.

We will now start creating an EGL program part, that is the main logical unit used to generate a Java program, a Java wrapper, or an Enterprise JavaBean session bean. We will create a called program named TE01A that will receive the working storage. To create TE01W01, follow these steps:

  1. Select the project EGL_DEMO_Server In the workbench, click File => New => Program.
  2. Type demo.programs in the package to create a new package
  3. Type TE01A as the EGL Source file name. This will be also the program name.
  4. Select Basic as EGL program type
  5. Select Create as called program.
  6. Click Finish.
  7. You will notice some errors in the generated code. This is normal since you have to type the logic. Note that the called program TE01A will receive the working area TE01W01 and will use the sqlRecord TE01R01 to read the DB2 data. The code you must enter is shown in the Figure 11. Remember that you can use Ctrl + space to help the code.

    Figure 11. TE01A program logic

    package demo.programs;
    import demo.records.*;
    // basic called program
    program TE01A type basicProgram (tE01W01 TE01W01)     // Received record
    tE01R01 TE01R01; // SQL Record Data declaration
    
    function  main()
    move tE01W01.id to tE01R01.id;     // Move from work to record definition
    TE01_READ(); // read DB2 table
    if  ( tE01R01 is noRecordFound)        /* if not found*/
    tE01W01.MESSAGE = "Record does not exist";
    else
    tE01W01.MESSAGE = " ";
    move tE01R01 to tE01W01;        /* move from DB2 record to work*/
    end
      end
    
    function TE01_READ();        // function to read DB2 table
      try
    get tE01R01 usingKeys tE01R01.ID;       // DB2 select using Where ID = :ID
      end
    end
    end
    

    Spend a few minutes understanding the program logic. Program data other than parameters (TE01W01) must be declared. This is the reason for the SQL Record Data declaration: tE01R01 TE01R01; // SQL Record Data declaration.

    tE01R01 is the recordName and TE01R01 is the recordPartName. It is a good practice use lower case for the first name character used in the program (tE01R01 and tE01W01).

    The first statement to be executed in this program is under the function main() and will move the ID received in the working area tE01W01 to the file id defined in the sqlRecord tE01R01. The second statement to be executed is a function named TE01_READ(), that is defined in the end of the program logic. This function will execute a get statement that will read the data base using ID as the key.

  8. Move the cursor to the line where we have the statement get and using the context menu select SQL Statement => View. This statement will execute the DB2 command select shown in Figure 12:
    Figure 12. Select to be generated by the statement get TE01R01 usingKeys
    Figure 12. Select to be generated by the statement get TE01R01 usingKeys

3.3 Understand the EGL Build.

A build descriptor part was automatically created when when the EGL project was created. This part is always required in the EGL and controls the generation process. Build descriptor options specify how to generate and prepare EGL output. You do not need to modify it, it will be necessary to change it if we would like to generate for COBOL for instance (supported only in the Enterprise Developer).

Open the the file EGL_DEMO_Server.eglbld under the folder EGLSource. Select Show only specified options. If you want to understand its meaning, press F1 and check the Help. Close the editor after understanding the values. The build descriptor for the EGL Server is shown in Figure 13:


Figure 13. EGL Build descriptor for the server program
Figure 13. EGL Build descriptor for the server program

Later on we will need to update this build descriptor since we want to implement our server program as a remote server using TCP/IP as the communications protocol.

4. Debug/Run the EGL Server program

At this point we are ready to Debug the EGL created. EGL debugger lets you debug EGL code without requiring that you first generate output.

To Debug the Server program:

  1. Select TE01A and using the context menu select Debug EGL Program . The Debug perspective will open,
  2. Click Yes for the message "Program TE01A expects 1 parameter and was passed 0".
  3. Using the view Variables in the upper corner, expand TE01A and tE01W01 and enter the value 40 in the field ID (just double-click).
  4. Use the icon (step into) to step through the code until the statement following the get of the record. Check the results.

See figure 14 for the results for the value 40:


Figure 14. Debugging the EGL program TE01A
Figure 14. Debugging the EGL program TE01A

The EGL code can be debugged without generating code.

Run the program until its completion and close the Debug perspective.


Section II. Build the client side of the application

So we already implemented the model of the MVC architecture. We will now implement the view and the controller.

Remember that the JSF technology will be used to code this example. Studio provides tools for JSF, called Faces components. Remember that JSF is a UI framework that provides GUI components and an event model for developing dynamic data driven Web user interfaces. There are approximately 31 Faces components in Studio.

The following tasks need to be performed to implement the EGL client side in this example:

  1. Create a Studio project to work with EGL Web
  2. Create the JSF/EGL components
  3. Debug the entire application using EGL debugger

1. Create a Studio project to work with JSF/EGL

The EGL components that will use JSF, must be created under a specific type of project named EGL Web projects. In our application example we could create all components under this Web projects, but the reason that we decided to create the EGL server component in another EGL project, is that we want to make a clear separation between the server portion of the application (model of the MVC) from the client side (view/controller of the MVC).

To set up a new project in the Studio Workbench:

  1. Click File => New => Project.
  2. In the left pane click EGL. In the right pane, click EGL Web Project.
  3. Click Next and follow the wizard.
  4. Type EGL_DEMO_Client as Project Name, be sure that Create new project build descriptors) automatically and Configure advanced options are selected as seen in Figure 15.
  5. Click Next:
    Figure 15. Creating the EGL Web project
    Figure 15. Creating the EGL Web project
  6. In the dialog J2EE Settings Page enter EGL_DEMO_EAR as the EAR project. We don't want to have the generated Java code under the DefaultEAR project. Be sure that the J2EE level is 1.3 and click Next, in the dialog Features Page deselect WDO Relational database runtime, since we are not using those components in our example. This runtime does not need to be installed.
  7. Click Finish. If the Confirm Perspective Switch dialog appears, click Yes to open the EGL Web perspective. An EGL build descriptor is created under the folder EGLSource with the name EGL_DEMO_Client.eglbld.
  8. Open the file EGL_DEMO_Client.eglbld and check the option Show only specified options. See the build descriptors created in Figure 16. Even the client side (view/controller) does not use DB2; the default options will be specified and generated options will be created in the deployment descriptor environment. Also, since we are using EGL page handlers, J2EE is always set to YES. Close this editor.
    Figure 16. EGL build descriptor for the EGL Web client
    Figure 16. EGL build descriptor for the EGL Web client

2. Create the JSF/EGL components

Before we create the new JSF and EGL components in the EGL Web project created, we must be sure that the EGL components already created for the server are visible, since we need to use the already created basic record TE01W01 to pass the data.

2.1. Edit an EGL Web project build path

To include the EGL server project in the EGL Web project path, follow these steps:

  1. In the Project Navigator, right-click on the project EGL_DEMO_Client, then click Properties.
  2. Select the EGL Build Path option.
  3. Click the check box beside the project EGL_DEMO_Server.
  4. Click OK.

At this point we can start creating the JSP pages that we designed for our application. We will create three pages, the input page named TE01_Input, the result page named TE01_Result and the error page named TE01_Error.

2.2. Create the TE01_Input JSP

This page will be the input page. The user will type the ID value and will click a button to call the EGL Server program.

Follow these steps to create a TE01_Input. Using the EGL Web Perspective:

  1. Right-click on the project EGL_DEMO_Client then click New => Faces JSP file. The New Faces JSP File wizard opens.
  2. Name the Faces JSP file as TE01_Input and accept the default folder.
  3. Click Finish. The new file is added to the Web content folder of our Web project and the file opens in Page Designer. A file named TE01_Input.egl is generated under the folder EGLSource/pagehandlers.
  4. Type Inquiry STAFF as the page title:
    Figure 17. Creating TE01_Input FacesJSP
    Figure 17. Creating TE01_Input FacesJSP

    Now that we have a page defined, we should have a Faces Components drawer and an EGL drawer on the Palette. From here, we can use the EGL components already created, like the working area to be passed to the server program.

    Using the Page Designer editor perform the following modifications:

  5. Using the view Attributes on the lower left choose Heading 1.
  6. Drag and drop the option Record located in the EGL palette to the blank area of the page, as shown in Figure 18:
    Figure 18. Drag/Drop EGL record definitions at the Faces JSP
    Figure 18. Drag/Drop EGL record definitions at the Faces JSP
  7. Add the EGL record defined previously to the Page Data view as follows: When the Select a Record dialog opens, select TE01W01 and click OK. TE01W01 and its related fields are visible in the Page Data view:
    Figure 19. TE01W01 layout shown in Page Data view
    Figure 19. TE01W01 layout shown in Page Data view

Add the Input field, message and button

  1. Drag the record tE01W01 from the Page Data view to the JSP. The Insert Record dialog is displayed
  2. Select Updating an existing record
  3. Select ID as Input field
  4. Click Options... to change the properties of the button controls
  5. Select Submit button and type Call Server Program and deselect Delete button.
  6. Click Finish:
    Figure 20. Inserting JSF controls into TE01_Input
    Figure 20. Inserting JSF controls into TE01_Input

Make other changes to the JSP as follows:

  1. Delete the {Error Messages} generated and located near by the Call Server Program button
  2. Select the EGLID field and use the Attributes view and the Validation page to specify for the field ID: Value is required, Minimum length 1, Maximum length 3, Digits only for Constraint, and select Add Display Error control. Press PF1 if you want explanation for any of those options.
  3. Save the jsp created and Close the editor. The final result should be as shown in Figure 21:
    Figure 21. Page TE01_Input with all controls
    Figure 21. Page TE01_Input with all controls

2.3. Create the TE01_Result JSP

This page will bring the results when the query was successful executed.

As we already did for the input page, follow these steps using the EGL Web Perspective to create that page:

  1. Right-click on the project EGL_DEMO_Client then click New => Faces JSP File. The New Faces JSP File wizard opens.
  2. Name the Faces JSP file as TE01_Result and accept the default folder
  3. Click Finish. The new file is added to the Web content folder of our Web project and the file opens in Page Designer. A file named TE01_Result.egl is generated under the folder EGLSource/pagehandlers.
  4. Type the title STAFF Query Result
  5. Using the view Attributes on the lower left choose Heading 1
  6. Drag and drop the option Record located in the EGL Palette to the blank area of the page
  7. When the Select a Record dialog opens, select TE01W01 and click OK. TE01W01 and its related fields are visible in the Page Data view.
  8. Drag the record tE01W01 from the Page Data view to the JSP. The Insert Record dialog is displayed
  9. Select Displaying an existing record
  10. Select all fields, except MESSAGE and leave the default Output field as Control type
  11. Click Finish. See the options we used in Figure 22:
    Figure 22. Page TE01_ResultInsert control dialog
    Figure 22. Page TE01_ResultInsert control dialog

Make the following changes:

  1. Delete the message filed {Error Messages} generated.
  2. Open the Faces Components drawer and add the Command Button ( ) below the table in the JSP area
  3. Using the Attributes view, Format page type Return in the Label,
  4. Save and close the editor. The Results are shown in Figure 23:
    Figure 23. Page TE01_Result with all controls
    Figure 23. Page TE01_Result with all controls

2.4. Create the TE01_Error JSP

This page will show the error messages if the ID does not exist or if there is any other error.

As we already did for the other pages, follow these steps using the EGL Web Perspective to create that page:

  1. Right-click on the project EGL_DEMO_Client then click New => Faces JSP File. The New Faces JSP File wizard opens.
  2. Name the Faces JSP file as TE01_Error and accept the default folder
  3. Click Finish. The new file is added to the Web content folder of our Web project and the file opens in Page Designer. A file named TE01_Error is generated under the folder EGLSource/pagehandlers
  4. Type the title Error During Query.
  5. Using the view Attributes on the lower left choose Heading 1
  6. Move the mouse under the title and add a break lines, just pressing Enter
  7. Add a line like "See Below the error message trying to get the data" make this text as Heading 4
  8. Drag and drop the option Record located in the EGL Palette to the blank area of the page
  9. When the Select a Record dialog opens, select TE01W01 and click OK. TE01W01 and its related fields are visible in the Page Data view
  10. Drag the record tE01W01 from the Page Data view to the JSP. The Insert Record dialog is displayed
  11. Select Displaying an existing record
  12. Select the fields ID and MESSAGE, clear the label MESSAGE: and leave the default Output field as Control type
  13. Click Finish. See the options we used in Figure 24:
    Figure 24. Page TE01_Error insert control dialog
    Figure 24. Page TE01_Error insert control dialog

Make the following changes:

  1. Delete the message file {Error Messages} generated
  2. Open the Faces Components drawer and add the Command Button ( ) below the table in the JSP area
  3. Using the Attributes view, Format page type Return in the Label.
  4. Save and close the editor. The page is shown in Figure 25:
    Figure 25. Page TE01_Result with all controls
    Figure 25. Page TE01_Result with all controls

2.5 EGL Page Handler

An EGL pageHandler part (or, more simply, a page handler) controls a user's run-time interaction with a Web page. Specifically, the page handler provides data and services to JSP that displays the page. The page handler itself includes variables and the following kinds of logic:

  • An OnPageLoad function, which is invoked the first time that the JSP renders the Web page
  • A set of event handlers, each of which is invoked in response to a specific user action (specifically, by the user clicking a button or link)
  • Optionally, validation functions that are used to validate Web-page input fields
  • Private functions that can be invoked only by other page-handler functions

The pageHandler part should have no logic. It implements the controller of the MVC model. Although the part might include lightweight data validations such as range checks, it's best to invoke other programs to perform complex business logic so that you follow MVC principles. For example, you should use a called program for database access, as our sample application does.

If a Workbench preference is set to automatic build on save (the default), page-handler generation occurs whenever you save the page handler. In any case, when you generate a page handler, the output consists of the following objects:

  • The page bean is a Java class that contains data and provides initialization, data validation, and event-handling services for the Web page.
  • A <managed-bean> element is placed in the JSF configuration file in your project, to identify the page bean at run time.
  • A <navigation-rule> element is created in the JSF application configuration file to associate a JSF outcome (the name of the page handler) with the JSP file to be invoked.
  • A default JSP file is also generated if one does not exist. Again, the file name is specified in the view property of the page handler, and the location is the folder WebContent\WEB-INF.
  • All data tables and records that are used by the part handler are also generated. In our example is the working area TE01W01.

    Figure 26 shows the graphical representation of the JSF/ EGL model and its MVC model:


    Figure 26. Relationship between EGL and JSF components
    Figure 26. Relationship between EGL and JSF components

2.6. Create EGL PageHandler for TE01_Input

We need to add code for the button event of TE01_Input:

  1. Using the EGL Web Perspective, open the JSP file TE01_Input located under project EGL_DEMO_Client and folder WebContent.
  2. Click the Design tab to access the Design view, Right-click in the Page Designer, then select Quick Edit.
  3. The Quick Edit view opens, select a button command Call Server program component in the JSP.
  4. Look at the bottom of the screen, click Command in the event pane (left pane) of the Quick Edit view, then click in the script editor (right pane) of the Quick Edit view. The function displays. Type the page handler code for the function as shown in Figure 27. Remember that you can use Ctrl + Space to help write the code:
    Figure 27. EGL PageHandler for TE01_Input
    Figure 27. EGL PageHandler for TE01_Input

When the button is clicked the server program TE01A is called and the working area tE01W01 is passed with the value of ID as contents. After the call is executed the working storage will have either the values retrieved from the Server program or either an error message.

The system function setRequestAttr (key, argument) uses a specified key (like "work") to place a specified argument in the request object (tE01W01). We will retrieve the argument later in the pages that will receive the control. Its a way to pass objects between JSP pages using the statement forward. For retrieving the value we will use the function getRequestAttr.

If the field tE01W01.MESSAGE is empty it is because there is no errors, so we will forward to the page TE01_Result.jsp otherwise we will forward to the page TE01_Error.

We could use the statement forward arg1 to label "target"; instead of the setRequestAttr (key, argument).

Save and close the file. When we save it the JSP the EGL pageHandler is compiled (if the default is in effect) and the message below should be shown in the EGL Generation Results view:

IWN.VAL.9994.i 1/1 The part TE01_Input was generated 
using build descriptor EGL_DEMO_ClientWebBuildOptions
from file EGL_DEMO_Client/EGLSource/EGL_DEMO_Client.eglbld.
IWN.VAL.9996.i 1/1 Generation completed for TE01_Input with no errors.

Also notice that a pagehandlers.TE01_Input.java, demo.records.EzeTE01W01.java, demo.records.TE01W01.java and TE01W01BeanInfo.java are generated under the Java Resources folder, as well its *.class files under the folder WebContent/WEB-INF/classes.

2.7. Create EGL PageHandler for TE01_Result

We need to add code for JSP Result page. This page will receive the control when the message field in the working area is blank. That means that the record was successfully read.

Perform the following steps to add EGL code at the PageHandler initialization:

  1. Open the JSP file TE01_Result located under project EGL_DEMO_Client and folder WebContet
  2. Right-click within a blank area of a Faces JSP page. Click View Page Code
  3. Locate the function onPageLoad() and type the code shown in Figure 28. Ctrl + Space is handy here.
  4. Save and close the file. Again the Java code is generated and compiled. You should have no errors.
    Figure 28. EGL PageHandler for onPageLoad() function of TE01_Result
    Figure 28. EGL PageHandler for onPageLoad() function of TE01_Result

    The system function sysLib.getRequestAttr uses a specified key ("work") to retrieve an argument from the request object into a specified variable (tE01W01).

Perform the following steps to add EGL code to handle the Command button:

  1. Click the Design tab to access the Design view, Right-click in the Page Designer, then select Quick Edit.
  2. The Quick Edit view opens, select a button command Return in the JSP.
  3. Look at the bottom of the screen, click Command in the event pane (left pane) of the Quick Edit view, then click in the script editor (right pane) of the Quick Edit view. The function displays. Type the page handler code for the function as shown in Figure 29:
    Figure 29. EGL PageHandler for TE01_Result
    Figure 29. EGL PageHandler for TE01_Result

Save and close the file. Any errors must be corrected.

2.8. Create EGL PageHandler for TE01_Error

We need to add code for JSP Result page. This page will receive the control when the message field in the working area have a error message. That means that we had errors reading the database or the ID do not exist.

Perform the following steps to add EGL code at the PageHandler initialization:

  1. Open the JSP file TE01_Error located under project EGL_DEMO_Client and folder WebContent
  2. Right-click in the Page Designer, then select Quick Edit.
  3. The Quick Edit view opens, select a button command Return in the JSP.
  4. Look at the bottom of the screen, click Command in the event pane (left pane) of the Quick Edit view, then click in the script editor (right pane) of the Quick Edit view. The function displays. Type the EGL code: forward to "TE01_Input"; // Return to initial page.
  5. Right-click within a blank area of a Faces JSP page. Click View Page Code
  6. Locate the function onPageLoad() and type the code shown in Figure 30.
  7. Save and close the file. Again the Java code is generated and compiled. You should have no errors:
    Figure 30. EGL PageHandler for TE01_Error
    Figure 30. EGL PageHandler for TE01_Error

3. Debug the entire application using EGL debugger

Our EGL Server program was already debugged, now we can to do the same for the EGL PageHandler code without having to debug the Java generated code. To debug page handlers, as well as programs used in a J2EE context, you can use the local WebSphere Application Server test environment in debug mode.

Before debugging we will need to perform some setup:

  1. Create an WebSphere Application Server test environment server
  2. Prepare the server for EGL Web debugging
  3. Select a default Debug build descriptor
  4. Add breakpoints in the EGL code
  5. Test in Debug mode

3.1. Create an WebSphere Application Server test environment server

Using the wizard create a Server and its configuration. Follow the steps below:

  1. In the EGL Web perspective select File > New Other.
  2. Select Server in the left pane and then select Server and Server Configuration in the right pane. Click Next. The Create a New Server and Server Configuration wizard opens. This wizard creates a new server and configuration.
  3. Type EGL_Server as Server name.
  4. In the Server type list, select WebSphere V5.1 and Test Environment.
  5. Click Finish. The server appears in the Servers view and Server Configuration view. Select the Page Server in the bottom of the EGL Web Perspective.

3.2. Prepare the server for EGL Web debugging

To debug EGL Web programs that run in the WebSphere Application Server, you must prepare the server for debugging. The preparation step must be done once per server and does not need to be done again, even if the workbench is shut down.

To prepare a server for debugging, do as follows:

  1. Make sure the server is stopped.
  2. In the Server view, right-click on the server (EGL_Server). A context menu displays.
  3. Select Add EGL Debugger Jar Files. Later, if you want to debug the generated Java instead of EGL, right-click on the server again and select Remove EGL Debugger Jar Files. The server cannot be running when the EGL debugger jar files are added or removed.

3.3. Select a default Debug build descriptor

Since we have two EGL projects, the Server does not use the J2EE specifications and the EGL Web does use J2EE, so we will need to specify two different build descriptors to be used by the EGL Debug, since that the EGL debug also needs them to run.

The EGL Server program will use the build descriptor file EGL_DEMO_Server and the EGL Web will use EGL_DEMO_Client. The steps below show how to make those build descriptors the default for the debug for each project:

  1. Right-click on EGL_DEMO_Server folder and from the context menu, click Properties.
  2. Select EGL Default Build Descriptors.
  3. Select the EGL_DEMO_ServerJavaBuildOptions for the Target System and Debug build descriptor
  4. Click OK.
  5. Repeat for the EGL_DEMO_Client but select EGL_DEMO_ClientWebBuildOptions for the Target System and Debug build descriptor.
  6. Click OK.

3.4. Add breakpoints in the EGL code

A breakpoint causes the execution of a program thread to suspend at the location where the breakpoint is set. A Breakpoints can be enabled and disabled via their context menus in the Breakpoints view. When a breakpoint is enabled, it will cause a thread to suspend whenever the breakpoint is reached. Enabled breakpoints are indicated with a blue circle. We will add 3 breakpoints, 2 in the EGL pageHandlers before and after calling the EGL Server and other at the EGL Server in the first program statement.

To add breakpoints in TE01_INPUT:

  1. Using the EGL Web Perspective, open the JSP file TE01_Input located under project EGL_DEMO_Client and folder WebContent.
  2. Click the Design tab to access the Design view, Right-click in the Page Designer, then select View Page Code.
  3. Position the cursor at the breakpoint line in the left margin of the Source view and double-click as shown in Figure 31.
  4. Close the files being edited:
    Figure 31. Adding breakpoints in the EGL pageHandlers
    Figure 31. Adding breakpoints in the EGL pageHandlers
  5. Using the folder EGL_DEMO_Server, add a breakpoint in the file TE01A.egl under the folder EGLSource and package demo.programs, as shown in Figure 32. Close the file after setting the breakpoint:
    Figure 32. Adding breakpoints in the EGL Server TE01A
    Figure 32. Adding breakpoints in the EGL Server TE01A

3.5. Test in Debug mode

We are ready to test the EGL in debug mode.

  1. Under EGL Web perspective, right-click on the file TE01_Input.jsp under the folder EGL_Demo_Client/WebContent, and click Debug on Server.
  2. The Server Selection dialog will be shown. Use the EGL_Server already prepared for the EGL Debug. Also select Set server as project default
  3. Click Finish. Be patient, since it will start the application server in debug mode and could take a while.
  4. The Debug perspective will open and a step-by-step debug dialog will open. Select Skip and Disable step-by-step mode, since we want to stop only at our breakpoints and click OK.
  5. You will stop at the statement shown here:
  6. To resume, select Run => Resume or just press F8.
  7. Use the Web browser page to enter the data. Enter a valid value such as 40 and an invalid one such as 44 to check the results.
  8. Click on the Debug page in the upper left and use the icons for the debug.
  9. When it stops in the call statement, use the icon for Step Into (F5), you will be able to debug TE01A also. Figure 33 below show the debug before calling the Server Program:
    Figure 33. Using the EGL Debugger with JSF
    Figure 33. Using the EGL Debugger with JSF

    Depending on the level of your code, you may have an error when accessing the database:

    VG0712E Cannot connect to the default database. The name of the default database was not specified
    VGJ004I The error occurred in TE01A, function TE01_READ.

    This is a known issue. But since we had already debugged the TE01A server program we can just ignore this problem

  10. After finishing the debug, close the debug perspective, go to the Server view and stop WebSphere Application Server.

Section III. Generate the code and prepare the run-time environment under WebSphere Studio

At this point the application is running well and was tested using the EGL debugger. You can see at the folder EGL_DEMO_Server/JavaSource that no Java code was generated for the EGL server program. Now, we need to prepare our environment, generate the Java server code and run the server application in a remote location using TCP/IP as protocol (in the Enterprise Edition this could be generated to run under COBOL/CICS on z/OS).

The steps required are:

  1. Add linkage options to call the server using TCP/IP
  2. Generate the Client and Server Java code
  3. Set up the TCP/IP listener, create the run configuration
  4. Run the application using the generated code

Show me an animation of this section running under WebSphere Studio.

1. Adding linkage options to call the server using TCP/IP

Since our server program could be in another machine, we will need to prepare the build descriptor to specify how to communicate and invoke this program. Since the client EGL code (the pagehandler) will call the server program, we need to update its build descriptor and inform where the server is located, which protocol to use, and so on.

Since our server program will be generated as Java, the only protocol that is allowed here is the use of TCP/IP. If we implemented our server with COBOL on CICS for z/OS,, we would need to use the Enterprise Developer version of studio and in that case we could use CICS instead, but this will be the subject of future article.

Here we will change the build descriptor and add the option linkage that contains the name of the linkage options part that guides aspects of generation.

  1. Using the EGL perspective (not EGL Web) open the build descriptor EGL_DEMO_Client.eglbl under the folder EGL_DEMO_Client/EGLSource.
  2. Change the option linkage adding a name like linkage_java_server. See figure 34.
  3. Save the file, but do not close it. Errors are OK since the linkage needs to be defined:
    Figure 34. EGL_DEMO_Client build descriptor
    Figure 34. EGL_DEMO_Client build descriptor

Using the EGL Perspective, add a Linkage options part:

  1. In the Outline view (lower left) , right-click on the EGL_DEMO_Client build file, then click Add Part:
    Figure 35. Add Part
    Figure 35. Add Part
  2. Click Linkage Options, then click Next.
  3. Type linkage_java_server as name for your linkage options part
  4. Click Finish. The linkage options part is added to the EGL file and the linkage options part page is opened in the EGL build parts editor.

Now we need to add a callLink element that specifies how the server program TE01A will be called:

  1. Click the Show CallLink Elements button on the editor toolbar (this is the default mode).
  2. Click Add and type the Program Name (TE01A) or select a program name from the Program Name drop-down list.
  3. Click the Type field and select remoteCall
  4. Click somewhere in the properties section to case the list of properties to be refreshed.
  5. Modify the CallLink elements list as shown in Figure 36:
    Figure 36. Linkage_java_server contents
    Figure 36. Linkage_java_server contents
  6. Save and close the files.

Some comments:

  • location specifies the location (hostname) of the machine where the called program is running. If the server program will be generated in another server instead of localhost you must specify its TCP/IP address.
  • package identifies the Java package in which a called Java program resides. In our example the TE01A program is in the package demo.programs.
  • remoteBind specifies whether linkage options are determined at generation time or at run time. We will use GENERATION since we don't want to include a linkage properties file in the run-time environment.
  • remoteComType specifies the communication protocol used. We will use TCP/IP since the middleware uses TCP/IP.
  • serverID specifies the TCP/IP port number of a called program's listener (supplied by EGL). We will have to remember that value (6666) when we will start the Server listener program.

2. Generate the Client and Server Java Code

Generation with EGL validates your declarations and creates output, including source code. In this tutorial we will generate Java to run under Windows. We can choose between two techniques: generating into a project (recommended) or generating into a directory.

Generating in the Workbench is accomplished with either the generation wizard or the generation menu item. When you select the generation menu item, EGL uses a specified default build descriptor. If you have not selected a default build descriptor, use the generation wizard.

To generate the EGL Server program:

  1. Using the EGL Perspective, select the EGL program TE01A under the folder EGL_DEMO_Server/EGLSource/demo.programs in the Project Navigator. Right-click, then select Generate with Wizard.
  2. Select TE01A in the Generate page and click Next.
  3. Be sure that the EGL_DEMO_ServerJavaBuildOptions build descriptor is selected and click Finish. The generation will create Java code under the folder JavaSource as well a file named vgj.properties that will be used to access the database. See the output in Figure 37:
    Figure 37. Java code generated for TE01A server program
    Figure 37. Java code generated for TE01A server program

Generate the EGL Client code.

  1. Using the EGL Perspective, select the folder EGL_DEMO_Client in the Project Navigator, right-click, then select Generate with wizard..
  2. Select TE01_Error, TE01_Input and TE01_Result in the Generate page and click Next. Be sure that the EGL_DEMO_ClientWebBuildOptions build descriptor is selected, and click Finish. The Java code is generated. You should have no errors.

3. Set up the TCP/IP listener, create run configuration

To invoke the the generated TE01A server program, an EGL TCP/IP listener program needs to be started on the execution machine. For this listener, a properties file named tcpiplistener.properties is needed. To create it:

  1. Using the EGL perspective and the Project Navigator view, right-click the folder EGL_DEMO_Server from the pop-up menu, select New => Other => Simple => File.
  2. Type the File name tcpiplistener.properties and click Finish.
  3. This file will be open. Type tcpiplistener.port=6666, Remember this is the port number that was specified in the callLink. Save and close this file. See figure 38:
    Figure 38. TCPIPlistener properties file
    Figure 38. TCPIPlistener properties file

Create a run configuration to start the TCP/IP Listener as a Java application:

  1. Select the EGL_Demo_Server project.
  2. Click on the pull down symbol to the right of the run icon (running man) in the task bar and select Run.
  3. On the Run Launch configuration page, select Java application in the Configurations panel on the left
  4. Click the New push button at the bottom of the Configurations Panel
  5. In the Main class field of the center panel, enter like CSOTcpipListener,(case sensitive) and set the configuration name at the top to one you recognize, such as TCPIPListener. Click Apply:
    Figure 39. Creating a run configuration for the TCPIPListener
    Figure 39. Creating a run configuration for the TCPIPListener

To start the TCPIPListener:

  1. Click on the Run push button. This starts the TCP/IP listener application. You can switch to the debug perspective to verify that it is running. The TCP/IP Listener has access to all the programs in the EGL_Demo_Server project:
    Figure 40. TCPIPListener running
    Figure 40. TCPIPListener running
  2. We are almost ready to test the application. Since the server program uses DB2, we must be sure that the JDBC classes needed to access the database are available to the server program. To be sure of this, add its JAR files to the server project.

To add the DB2 JDBC driver zip file as an external jar in the build path of the EGL_Demo_Server project:

  1. Select the EGL_Demo_Server project, and from the project's context menu, select Properties.
  2. Select Java build path and the Libraries tab.
  3. Click on Add External Jars.
  4. Navigate to the DB2 Java zip file, such as C:\SQLLIB\java\db2java.zip.
  5. Select the db2java.zip file and click Open to add the JAR file to the Java build path.
  6. Click OK

4. Run the application using the generated code

At this point we are ready to test the whole application. Make sure that BTCPIPListener is running (move to Debug perspective) and ready to receive TCP/IP calls on Port 6666.

Test the TE01_Input.jsp:

  1. Using the EGL Web perspective, in the Project Navigator view, right-click on the JSP page TE01_Input.jsp in folder EGL_DEMO_Client/WebContent and select Run on Server.
  2. When the browser opens, type a valid ID such as 40 and click the button.
  3. The results should look like Figure 41 below:
    Figure 41. Testing the application: Page TE01_Result with data
    Figure 41. Testing the application: Page TE01_Result with data

Testing errors:

  1. Click Return to return to TE01_Input.
  2. Use invalid data such as XX:
    Figure 42. Entering invalid data
    Figure 42. Entering invalid data

Use an invalid ID such as 44. See the results in Figure 43:


Figure 43. Entering invalid ID
Figure 43. Entering invalid ID

Congratulations! You did a simple application. Remember that you have stop the Java listener and the Application Server.

The easiest way to stop the listener and application server is to go to the Debug perspective and, using the context menu in the Debug view, select Terminate all and Remove All Terminated.


Section IV. Deploy the client and server using WebSphere Application Server V 5.1

This section is optional and requires WebSphere Application Server V5.

Show me an animation of this section.

At this point we are ready to move our application to production. Figure 44 shows how we would implement our application. We could have two different machines. One running the Application Server that will have the Client side (view and controller from the MVC) and another machine that has the Java server code (model from the MVC) and the TCPIP listener:


Figure 44. Run-time architecture using TCP/IP listener and WebSphere Application Server
Figure 44. Run-time architecture using TCP/IP listener and WebSphere Application Server

1. Export the client J2EE application into an EAR file

J2EE applications are deployed in the form of an EAR file. Use the Export wizard to export into an EAR file for deployment.

To export an enterprise application project into an EAR file:

  1. In any perspective, select File > Export.
  2. Select EAR file and click Next.
  3. In the Enterprise application project name field, select EGL_DEMO_EAR.
  4. In the Destination field, enter C:\Program Files\WebSphere\AppServer\installableApps\EGL_DEMO_EAR.ear.
  5. Click Finish.

2. Deploy the called Java server code outside of J2EE

To deploy a Java application outside of J2EE, you have to:

  1. Install the EGL run-time code for Java. If you will need to run the server in another machine, you will need to perform such activity. Use the Studio help and search for that phrase. We assume that all will be under the same machine for simplicity
  2. Export the EGL-generated code into JAR files
  3. Include the exported files in the classpath of the target machine.

2.1 Export the EGL-generated code into jar files

To export the Java generated code into an JAR file:

  1. In any perspective, select File => Export.
  2. Select JAR file and click Next.
  3. Select the project EGL_DEMO_Server
  4. In the destination field, enter C:\EGL_SERVER_JAVA\EGLDemoServer.jar.
  5. Click Finish:
    Figure 45. Creating the JAR file
    Figure 45. Creating the JAR file

2.2 Include the EGL jar and exported files and the TCP/IP listener in the classpath of the target machine.

Do this using the Windows environment variable. See an example in Figure 46 below.

You must add the jar that we just created and also the jar file that is needed for the TCPIPlistener the files are:

  • C:\EGL_SERVER_JAVA\EGLDemoServer.jar
  • C:\AD512\wstools\eclipse\plugins\com.ibm.etools.egl.generators_5.1.2\runtime\EGLTcpipListener.jar

EGL_SERVER_JAVA is where the EGL Server was exported and AD512 is where Studio is installed.


Figure 46. Adding the JAR file in the Windows classpath
Figure 46. Adding the JAR file in the Windows classpath

If your server that will run the TE01A program is in another machine, install the EGL run-time code for Java. If the machine runs Windows, just move to that machine the Jar files fdaj.jar and fda.jar and add at its Windows classpath.

3. Start the TCP/IP listener

To start the listener from the windows command line, run the program:

java CSOTcpipListener C:\AD_Workspace\EGL_DEMO_Server\tcpiplistener.properties

Change the location of your properties, in our example C:\AD_Workspace\EGL_DEMO_Server. The best way to find it is to use Studio and select the file tcpiplistener.properties, located under the folder EGL_DEMO_Server. Right-click and select Properties, then cut and paste the location from there. If you use another machine you must copy this file.

If you added the jar at the windows classpath as explained before, the TCP/IP listener will be started and it must be running the whole time. You should get a screen like the one shown in Figure 47. To end this program, just type Ctrl + C.


Figure 47. TCP/IP Listener running
Figure 47. TCP/IP Listener running

4. Install the J2EE client Application into WebSphere Application Server V5.1

You can close Studio now since you won't need it anymore.

To Deploy the exported EAR file to the Application Server:

  1. Start the HTTP Server and the Application Server.
  2. Using the Application Server Administrative Console use the options:
    1. Applications => Install new application C:\Program Files\WebSphere\AppServer\installableApps\EGL_DEMO_EAR.ear
    2. Follow the wizards and click Next until you get the message Application EGL_DEMO_EAR installed successfully.
    3. Save the configuration.
  3. After the Application is installed it must be started:
    Figure 48. Installing the client J2EE into WebSphere Application Server
    Figure 48. Installing the client J2EE into WebSphere Application Server

Test the application using the Application Server and the TCPIPListener.

The TCP/IP Listener must be running as explained before.

To test the application, just point your browser to http://localhost/EGL_DEMO_Client/faces/TE01_Input.jsp

You must have the first Web screen as shown. Type a valid ID such as 60 and you should get the result shown in Figure 49:


Figure 49. Using a valid ID
Figure 49. Using a valid ID

Congratulations again! Now you moved your application to production. If the Server code move to another machine you will need to update the callLink elements that are in the linkage part of the build descriptor and regenerate the code. A future article will show how to deploy to COBOL/CICS using WebSphere Studio Enterprise Developer.

Conclusion

Without writing a single line of Java code, you've tested and published a program that uses JSF architecture and created JavaBeans and JSPs by using EGL and Studio. Also your code was deployed to WebSphere Application Server version 5.1 using a very good MVC model. The server code used TCP/IP as middleware. Our example was a very simple application, but the process for create, test and deploy a very sophisticated application would be basically the same as described here.

Acknowledgements

The author wishes to thank Henry Koch, who helped with the sample application, and Jonathan Sayles and Mark Evans, who reviewed and contributed to the article.



Download

NameSizeDownload method
EGL_JSF.zip6.9 MBFTP|HTTP

Information about download methods


Resources

About the author

Photo of Reginaldo Barosa

Reginaldo W. Barosa is an IBM Certified Application Development Specialist. He provides sales support, helping customers with enterprise transformation solutions and development tools, such as WebSphere Developer for System z. Before joining IBM US, Reginaldo worked for 27 years in IBM Brazil. He has co-authored IBM Redbooks and has written books, as well as other articles for IBM developerWorks. He holds a degree in Electrical Engineering from Instituto Mau de Tecnologia, Sao Paulo, Brazil.

Report abuse help

Report abuse

Thank you. This entry has been flagged for moderator attention.


Report abuse help

Report abuse

Report abuse submission failed. Please try again later.


developerWorks: Sign in


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Select information in your profile (name, country/region, and company) is displayed to the public and will accompany any content you post. You may update your IBM account at any time.

Choose your display name

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


Rate this article

Comments

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=WebSphere
ArticleID=13691
ArticleTitle=Generating Java using EGL and JSF with WebSphere Studio Site Developer V5.1.2
publish-date=08012004
author1-email=rbarosa@us.ibm.com
author1-email-cc=