< Previous | Next >

Module 2: Add advanced features

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.

Learning objectives

This module teaches you more powerful ways to use data from a database. In this module, you will:
  • Format database records on a Web page
  • Add a component that allows uploading files to a database from a Web page
  • Navigate from page to page automatically
  • Automate some database administration tasks

Time required

This module should take approximately 1 hour and 30 minutes to complete. If you decide to explore other facets of dynamic Web sites while working on the tutorial, it could take longer to finish.

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:
  1. Import the project. Switch to the Web perspective (Window > Open Perspective > Web).
  2. In the Enterprise Explorer view of the Web perspective, ensure that your ClassifiedsTutorial project looks like the following image:
    Enterprise Explorer view.
To set the target server:
  1. In the Enterprise Explorer view of the Web perspective, right-click ClassifiedsTutorial and select Properties
  2. In the properties list, click Server.
  3. In the Default server list, select the server that you want to use as the default. Click Apply.
  4. In the properties list, click Targeted Runtimes.
  5. 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:
  1. Right-click all_records.jsp file, then select click Run As > Run on Server.
  2. Choose Manually define a new server.
  3. Select a server you have installed.
  4. 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:
  1. In the Enterprise Explorer view, right-click ClassifiedsTutorial and select Properties. The Properties for the ClassifiedsTutorial window opens.
  2. Click JDBC Connections.
  3. In the JDBC Connection properties, click New. The Profile Browse dialog opens.
  4. In the Profile Browsedialog, click New. The New Connection Profile dialog opens.
  5. In the Connection Profile Types list, select Derby, then click Next. The Create Connection Profile dialog opens.
  6. In the Name field, type DerbyDB, select Auto-connect at startup, then click Next.
  7. In the Drivers field, select Derby 10.2 - Embedded JDBC Driver Default.
  8. 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.
  9. You may need to enter a User ID to access the database. A password is not required.
    Tip: Any User ID will work.
  10. In the New Derby Connection Profile wizard, click Finish.
  11. 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.

Lessons in this module

< Previous | Next >

Feedback