< Previous | Next >

Lesson 2: Create the projects and import the database

In this lesson, you will create projects to hold your EGL application and add a database to use.

In this tutorial, you will spend most of your time working with files in an EGL web project. This project will contain the EGL code, web pages, and sample database that make up the logic, interface, and data for the application. Before you begin creating projects, however, you need to decide which server you will use in the tutorial.

If you choose WebSphere® Application Server, you will need an Enterprise Application Resource project (EAR project) in addition to the EGL web project. The EAR project contains information about deploying an application in the J2EE framework, including how to run it on a server and how to connect it to data sources. An EAR project can contain one or more other projects, meaning that the EAR project contains information on deploying those projects. The projects contained by an EAR project are called modules. In this case, your EGL web project will be a module within the EAR project. In a large application, an EAR project could have many different types of modules doing different jobs.

If you choose Apache Tomcat, however, you will not need an EAR project, and in fact, you will not be able to use an EAR project. WebSphere Application Server is a full-featured application server that can run each of the types of modules in the J2EE framework, including web projects (like your EGL web project), EAR projects, and Enterprise JavaBean (EJB) projects. On the other hand, Tomcat is a web server, designed to run only web projects; it does not support other types of J2EE projects such as EAR projects or EJB projects.

The tutorial application will run the same way regardless of which server you use, but you should be aware of the differences between the servers. If you use WebSphere Application Server, you will create an EAR project and put the database connection information in that EAR project. If you use Tomcat, you will put the database connection information directly into the EGL web project.

For the rest of the tutorial, be aware of sections that apply to WebSphere Application Server or to Apache Tomcat. If the instructions refer to projects, files, or options that you do not have, check to see that you are in the correct section for your server.

Installing the server (WebSphere Application Server)

WebSphere Application Server typically requires a separate installation process from your EGL product. You must install WebSphere Application Server into the same package group that contains your EGL product. If you can see WebSphere Application Server in the Servers view, located by default at the bottom of the workbench, then the product is installed. If not, you must buy the product or use Tomcat instead.
The product is visible in the Servers view.

Installing the server (Tomcat)

Installing Tomcat is usually as easy as downloading and unzipping the server files and then telling the workbench where to find them. Follow these steps to install and configure Tomcat 6.0:
  1. In the Servers view, located by default at the bottom of the workbench, right-click anywhere in the blank space, then click New > Server.
  2. In the Define a New Server window, expand IBM if necessary and select the version of Tomcat that is installed on your system, or that you wish EGL to install on your system for you. If you select a version with debug support, you can step through your programs in the EGL debugger.
    The Tomcat server in the New Server window.
  3. In the Tomcat Server window, you have an option:
    • If you have already installed Tomcat to your system, browse to the Tomcat installation directory.
    • If you have not yet installed Tomcat, click Download and Install and follow the instructions on your screen. Repeat this step when you have installed the software.
    The Tomcat server window.
  4. Click Finish. The new server is displayed in the Servers window.
  5. Leave the EGL Workbench for a moment and use Windows Explorer to browse to the folder where you installed Tomcat. Look for the lib folder inside this folder. For example, the path might look like this:
    D:\Program Files\Apache\lib
    Make sure this folder contains a file named derby.jar. If not, copy the file into the lib folder from the following folder in your installation directory:
    installation_directory\plugins\org.apache.derby.core_10.1.2.1

Create the EGL web project (either server)

Because your project will have a web page interface, you need to create an EGL web project. An EGL web project combines the features of a dynamic web project and an EGL project. If you are using WebSphere Application Server, you will also create an EAR project.

  1. Click the New EGL Project icon in the top left of the workbench.
    The New EGL Project icon.
    EGL displays the New EGL Project wizard.
  2. Alternatively, you can click File > New > Other, then in the Select a Wizard dialog, expand the EGL folder and click EGL Project, then click Next.
    The Select a Wizard dialog shows the EGL folder and the EGL Project icon inside it.
    EGL displays the New EGL Project wizard.
  3. In the Project name field, enter this name for your project:
    EGLWeb
  4. Under EGL Project Types, click Web Project. Click Next.
    The New EGL Project wizard shows the different project types.
  5. Click Next.
  6. In the Target Runtime field, select the name of the application server that you verified at the beginning of this lesson.
  7. Under Build Descriptor Options, make sure that Create a new build descriptor is selected.
  8. Select the Show Advanced Settings check box and click Next.
  9. Leave the Use the default location for the project check box selected.
  10. If you are using WebSphere Application Server, the Add project to an EAR check box should be selected, and the name EGLWebEAR should appear for the EAR project name. Accept both of these defaults.
  11. You do not need to change anything in the Modify project facets section.
  12. Clear the Create an EGL deployment descriptor check box. EGL deployment descriptor files contain information on deploying and using web services. This tutorial does not connect to any web services.
    Picture of the New EGL Web Project window using WebSphere Application Server
  13. Click Finish.
  14. You may see a message asking if you want to switch to the J2EE perspective. If you see this message, click No.
The new project or projects are created in your workspace. The workbench may display a Technology Quickstarts window with Help information. You can close this window.

Import the database

This tutorial includes a sample Derby database to be used in your application. In these steps, you add this database to your project. For more information on Apache Derby, an open-source relational database, see http://db.apache.org/derby/.
  1. Click the following link and download the sample database to a temporary folder on your computer, such as your desktop:

    Sample database

    It does not matter where you save the database, as long as you can find it again later.

    Alternately, you can find this sample database in your product installation directory in the following location:
    shared_resources/plugins/com.ibm.etools.egl.tutorial0001.doc_version/
       resources/EGLDerbyDB.zip
    shared_resources
    The shared resources directory for your product, such as C:\Program Files\IBM\SDP70Shared on a Windows system or /opt/IBM/SDP70Shared on a Linux system. If you installed and kept a previous version of an IBM® product containing EGL before installing your current product, you may need to specify the shared resources directory that was set up in the earlier installation.
    version
    The installed version of the plugin. If more than one is present, use the one with the most recent version number, unless you have a reason to use an older version.
  2. In the workbench, click File > Import.
  3. In the Import window, expand General, click Archive File, then click Next.
  4. In the Archive file window, From archive file field, enter the location of the file you just downloaded. You can use the Browse button to find it.
  5. At the bottom of the wizard, next to the Into folder field, click the Browse button.
  6. In the Import into folder window, expand EGLWeb, click the WebContent folder to select it, then click OK. This folder is where the database will be added to your project. The Import window looks like this:
    Picture of the Import window
  7. Click Finish.
The database is added to your workspace in the WebContent folder of the EGLWeb project. Do not edit any of the files in the database directly. Later, you will create an EGL application to view and edit this database.

Lesson checkpoint

In this lesson, you created one or two projects, depending on your server. You can explore the project or projects in the Project Explorer view:
  • The EGLWeb project will contain the EGL code, web pages, and other files associated with the application. In particular, you will work with the EGLSource and WebContent folders which will contain the EGL source code files and the web pages for the application, respectively.
  • The EGLWebEAR project is the Enterprise Application Resource for the EGLWeb project. You have this project only if you are using WebSphere Application Server.

The Enterprise Explorer view looks like this if you are using WebSphere Application Server:

Picture of the Enterprise Explorer view including the EGL web project and EAR project

The Enterprise Explorer view looks like this if you are using Tomcat:

The Enterprise Explorer view includes the EGLWeb project

< Previous | Next >

Feedback