The Pizza on the Web program lets you interact with a DB2 or
Informix database (EGLSAMP) by way of a Web browser. The database
resides on the Web Application Server and is accessed by the JNDI
name jdbc/EGLSAMP.
You may run the Pizza on the Web application using either a
WebSphere v5.x Test Environment server or a WebSphere v6 server. If
you want to use a v5.x server you must have previously installed the
WebSphere test environment v5.x feature. By default the sample is set
up to run using a v6 server. To use a v5.x server you must take the
following steps when you import the sample and the first page of the
new sample wizard is displayed:
- Click the Hide Advanced button
- From the Servlet Version dropdown list select 2.3
- From the Target Server dropdown list select
WebSphere Application Server V5.1
After you have imported the sample, do as follows to set up a test
server (which accesses the database) and to run the sample programs:
- Expand the project and the EGLSource directory to see the EGL
files used in the sample
- Expand the WebContent folder to see the Java Server Faces JSP
files used in the sample
- Create a database named EGLSAMP:
- If you are using a DB2 database, use DB2 facilities to create
the database. If you are using DB2 V8.1, you can use the Control
Center to create the database; enter the database name and accept
all defaults. To use the v6 server, the minimum DB2 version
required is V8.1.6
- If you are using an Informix IDS database, use dbaccess or the
Informix Server Administrator to create the database. Set the
logging mode of the database to ANSI-compliant unbuffered logging.
- Configure a web server with a data source to access the EGLSAMP
database. The instructions for configuring a data source are
dependent on the application server version and the database manager
being used.
For the v5.1 Test Environment server
- Open the Web perspective (Select Window->Open
Perspective-> Web ).
- Click on the Servers view tab
- Right click within the Servers view, select New->Server
- On the Define a New Server dialog select server type WebSphere
v5.1 Test Environment
- Press Next and press Next on the following dialog
- On the Add and Remove Projects dialog, select project
EGLPizzaOnTheWebEAR
- Press Add, then press Finish
- Right click on the new server entry in the Servers View and
select Open.
- Configure the data source
If you are using a DB2 database
- Select the Data source tab.
- Select Default DB2 JDBC provider in JDBC provider list and
press the SECOND Add button (the one next to table titled Data
source defined in the JDBC provider selected above.)
- Select DB2 JDBC Provider and press next.
- Change JNDI Name to jdbc/EGLSAMP and press next
- Select databaseName, change value to EGLSAMP, and press
finish.
If you are using an Informix IDS database
- Select the Security tab. Click Add
- In the Alias text box, enter an arbitrary name for the entry.
In the User ID and Password text boxes, enter the User ID and
password used to login to the instance of IDS that contains
EGLSAMP. Entering a description in the Description text box is
optional. Click Ok
- Select the Data source tab.
- Highlight each entry in the JDBC provider list and click
remove. There should be no entries in the list. Click Add.
- In the Database type list box of the Create a JDBC Provider
screen, select Informix. In the JDBC provider type list box,
select Informix JDBC Driver. Click Next.
- In the Name text box, type a name for the data source. Click
Add External JARs.
- In the Select JAR file window, browse to the installed
location of your Informix JDBC Driver.
- Double-click the /lib folder and select ifxjdbc.jar. Click
Open.
- In the Create a JDBC Provider window, click Add External JARs.
- In the Select JAR file window, browse to the installed
location of your Informix JDBC Driver.
- Double-click the /lib folder and select ifxjdbcx.jar. In the
Create a JDBC Provider window, click Finish.
- In the table labeled JDBC provided list, select the
newly-created JDBC provider. Click the Add button that is across
from the table labeled Data source defined in the JDBC provided
selected above ( second one from the top ).
- In the Select the type of JDBC provided window, select
Informix JDBC Driver. Click Next.
- In the Name text box, change the name to EGLSAMP.
- In the JNDI name text box, change the name to jdbc/EGLSAMP.
- In the Component-managed authentication alias drop down list,
select the JAAS authentication entry created earlier. Click Next.
- Select databaseName, enter EGLSAMP. Enter the appropriate
values for serverName, portNumber, and ifxIFXHOST. Click Finish.
- Close and save the server definition.
- Right click on server definition and select publish.
For the v6.0 Application server
- Open the Web perspective (Select Window->Open
Perspective-> Web ).
- Click on the Servers view tab
- If there is not already a v6 server defined
- Right click within the Servers view, select New->Server
- On the Define a New Server dialog select server type WebSphere
v6.0 Server
- Press Next and press Next on the following dialog
- On the Add and Remove Projects dialog, select project
EGLPizzaOnTheWebEAR
- Press Add, then press Finish
- Right click on the v6 server entry in the Servers View and
select Start. Wait until the server status changes to Starting,
then to Started
- Right click on the started v6.0 server and select Run
administrative console
- On the Welcome page, enter a user ID and select Log in
- Expand the Security node on the left and select Global security
- Under Authentication, select J2C Authentication data
- Select New
- Enter an Alias, for example, EGLSAMPUser
- Enter a User ID that can access the EGLSAMP database
- Enter a password for the user ID
- Select Apply
- Configure the data source
If you are using a DB2 database
- Expand the Environment node on the left and select WebSphere
Variables
- Select the Server scope radio button
- In the variable list select the variable
DB2UNIVERSAL_JDBC_DRIVER_PATH
- In the value field enter the directory containing the DB2 JDBC
drivers. By default this is C:\Program Files\IBM\SQLLIB\java on a
Windows system
- Select Apply
- Expand the Resouces node on the left and select JDBC Providers
- Select the Server scope radio button
- Select New above the Providers list, which may be empty
- On the JDBC Providers page, for Step 1 select DB2. For Step 2
select DB2 Universal JDBC Driver Provider, and for Step 3 select
Connection pool data source.
- Select Next
- On the General Properties page, select Apply
- Under Additional Properties, select Data sources
- On the data sources page select New
- Under General Properties, enter JNDI name jdbc/EGLSAMP
- For database name enter EGLSAMP
- For Server name enter localhost if the database server is
local to your machine, or the database server otherwise
- If your database server is not using the default port of
50000, enter the port
- Under Authentication, select the Component-managed
authentication alias dropdown symbol
- Select the alias created above to access the EGLSAMP database
- Select Apply
- In the Messages box at the top of the JDBC providers box
select the save link
- Select Save
If you are using an Informix database
- Expand the Environment node on the left and select WebSphere
Variables
- Select the Server scope radio button
- In the variable list select the variable
INFORMIX_JDBC_DRIVER_PATH
- Select the Properties view and in the value field enter the
directory containing the Informix JDBC drivers. The jar file names
expected to be in the directory by the v6 server are ifxjdbc.jar
and ifxjdbcx.jar
- Select Apply
- Expand the Resources node on the left and select JDBC
Providers
- Select the Server scope radio button
- Select New above the Providers list, which may be empty
- On the JDBC Providers page, for Step 1 select Informix. For
Step 2 select Informix JDBC Driver Provider, and For Step 3 select
Connection pool data source.
- Select Next
- On the General Properties page, select Apply
- Under Additional Properties, select Data sources
- On the data sources page select New
- Under General Properties, enter JNDI name jdbc/EGLSAMP
- For database name enter EGLSAMP
- Enter the name of your Informix Server
- In the ifxIFXHOST field enter the location of your Informix
database server
- If your database server is not using the default port of 1526,
enter the port
- Under Authentication, select the Component-managed
authentication alias dropdown symbol
- Select the alias created above to access the EGLSAMP database
- Select Apply
- In the Messages box at the top of the JDBC providers box
select the save link
- Select Save
- EGL page handler parts are automatically generated when saved.
Note: When you loaded this sample, the page handlers were
generated. Non-page handler parts are not generated automatically
on save. This is another good reason to keep your page handlers
small and to call program or library parts to do the detailed work.
Pre-generated Java files were included in the sample when it was
loaded to avoid unresolved references from the page handlers to
these other parts. However, those parts must be generated to put
information on how to access the EGLSAMP database into the Pizza
application's deployment descriptor.
To generate the non-page handler parts, do as follows:
- In the EGLSource/createTables folder, right-click on the file
CreatePizzaTables.egl and select Generate.
- In the EGLSource/data folder, right-click on the file
CustomerLib3.egl and select Generate.
- To start the Pizza sample, right-click on PizzaIntroduction.jsp
in the WebContent folder and select Run on server. Select the
server you just configured and press Finish.
|