In this module, you will learn how to use advanced features to
modify the format of your Web pages, add a feature that allows users to upload
files to the database, set up rules that will automatically send users to
a particular page, and automate some administrative tasks such as key generation.
Prerequisites
If you have already completed
Module 1: Creating Web pages with data connections, skip the rest of this
prerequisites section and begin working on Lesson 2.1: Format a data table.
If
you are beginning your work in this tutorial with module 2, without doing
module 1 first, you must first import the required resources, set up the target
server, and set up the database connection.
To import the required
resources:
- Import the project. Switch to the Web perspective
().
- In the Enterprise Explorer view of the Web perspective, ensure that your
ClassifiedsTutorial project looks like the following image:
To set the target server:
- In the Enterprise Explorer view of the Web perspective, right-click ClassifiedsTutorial and
select Properties
- In the properties list, click Server.
- In the Default server list, select the server that you want to use as
the default. Click Apply.
- In the properties list, click Targeted Runtimes.
- In the Runtimes list, click the runtime that corresponds with the server
that you selected. Click OK.
Note: If you do not see any servers listed in the Default server
list, and you have installed server runtimes, it is possible the server needs
to be configured. To configure a server, you can do the following:
- Right-click all_records.jsp file, then select click .
- Choose Manually define a new server.
- Select a server you have installed.
- Follow the directions in the wizard to configure the server. The first
time you run on server you may receive an error. To fix the error set the
target server as described above, restart the server in the Servers view,
and reload the Web page in the browser.
If you go back through the previously described steps for setting a target
server, you will now find the default server is the one you have just configured.
If a server is installed but not configured, it will not show up in the list
of servers from which you can choose a default target.
To set up
the database connection:
- In the Enterprise Explorer view, right-click ClassifiedsTutorial and
select Properties. The Properties for the ClassifiedsTutorial
window opens.
- Click JDBC Connections.
- In the JDBC Connection properties, click New. The Profile
Browse dialog opens.
- In the Profile Browsedialog, click New.
The New Connection Profile dialog opens.
- In the Connection Profile Types list, select Derby,
then click Next. The Create Connection Profile dialog
opens.
- In the Name field, type DerbyDB, select Auto-connect
at startup, then click Next.
- In the Drivers field, select Derby 10.2 - Embedded JDBC Driver
Default.
- In the Database location field, click Browse and
select <workspace_location>\ClassifiedsTutorial\WebContent\database,
where <workspace_location> is the directory of your
current workspace. Click OK.
- You may need to enter a User ID to access the database. A password is
not required.
Tip: Any User ID will work.
- In the New Derby Connection Profile wizard, click Finish.
- In the Profile Browse dialog, click DerbyDB, then
clickOK.
You can browse the files in the tutorial
Web project. To open a file, double-click it in the Enterprise Explorer view.
To view a map-like representation of how the pages are related, double-click Web
Site Navigation in the Enterprise Explorer.
The
majority of your work in this sample will involve the following files:
- all_records.jsp
- This is the site's home page. It will display every classified ad in the
database.
- new_record.jsp
- This page will create a new classified ad.
- update_record.jsp
- This page will change the details about an ad in the database or delete
it.
- classifiedTemplate.jtpl
- This is the template for the site pages. It includes elements like the
table and the gray "Welcome to the Classifieds" banner that are on every page.
This page also has two navigational tabs below the gray banner that lead to
the home page and the new classified ads page.