Legal | Privacy
Building JSP Applications that Use Oracle Text to Search Content in the Database using JDeveloper
 
 

Building JSP Applications that Use Oracle Text to Search Content in the Database using JDeveloper

Module Objectives

Purpose

This module describes how to use Oracle JDeveloper to build a Text and Catalog Search JSP Application using Wizards.

Objectives

After completing this module, you should be able to:

Invoke the Text Wizard to create and run a Text Search JSP application

Invoke the Catalog Wizard to create and run the Catalog Search JSP Application

Prerequisites

Before starting this module, you should have:

Reviewed the reference material below, if necessary, to gain a basic understanding of Oracle Text

Completed the Preinstallation Tasks module

Completed the Installing the Oracle9i Database module

Completed the Installing Oracle9i JDeveloper module
Loaded the PO Schema
Downloaded and installed the Oracle Text Wizards from OTN

Reference Material

The following is a list of useful reference material if you want additional information about the topics in this module:

Documentation: Oracle Text Application Developer's Guide

 

Overview

The Text and CatSearch Wizards are add-ins for JDeveloper9i which provide a menu-driven interface for generating simple Text and Catalog Search applications. The source code is generated through JDeveloper and can be easily modified.

 

Building a Text Search Application using the Text Wizard

In order to search for content in the ways this module will describe, you must perform the following steps:

1. Create a JDeveloper Project
2. Invoke the Text Wizard
3. Create an Index on Document
4. Configure HTTP Server to run the JSP Application
5. Run the Text Search JSP Application

 

Create a JDeveloper Project

Back to List

You need to create a workspace and project in JDeveloper before you can create your application. Perform the following steps:

1.

Open JDeveloper.

 

2.

Select File > New. Click the Projects category and select Workspace. Then click OK.

 

3.

Change the directory and file name as textsearch. Make sure Add a New Empty Project is checked and click OK.

 

4.

Enter the project directory and file name as textsearch and click OK.

 

5.

Once the project is created, you will see it in the System Navigator.

 

 

Invoke the Text Wizard

Back to List

The Text Wizard is designed to generate a JSP or PSP Text Search Application in JDeveloper that will utilize Oracle Text capabilities. Perform the following steps:

1.

You can now invoke the Text Wizard to create the application. Right-click on the textsearch.jpr project and select Invoke Text Wizard. Note: you can also select it from the Tools pulldown window.

 

2.

When the Welcome window appears, click Next.

 

3.

Enter the Application name as TextSearchApp and click Next.

 

4.

You will need to create a new connection to your PO database user. Click New.

 

5.

At the Connection Wizard welcome window, click Next.

 

6..

Enter the connection name po_JDBC and click Next.

 

7.

Enter the username and password po and click the Deploy Password checkbox and click Next.

 

8.

Enter your hostname and make sure the SID is correct and click Next.

 

9.

Click Test Connection to make sure it is successful and click Finish.

 

10.

All the connection information that you just created will be inserted into the Text Wizard connection window. Click Next.

 

11.

You will search the document column from the PO_PRODUCTS table. select PO_PRODUCTS for the Table Name and DOCUMENT(CLOB) for the Column name and click Next.

 

12.

On the Search page, you want to list the PRODUCT_NAME(VARCHAR2) and the DESCRIPTION(VARCHAR2). Select each column and click > to move them from the Available Columns to the Select Columns and click Next.

 

13.

Select all the Text Document Services checkboxes and click Next.

 

14.

Make sure the Document Format is set to html and the Source Type is jsp and click Next.

 

15.

At the Summary window, click Finish.

 

16.

The JSP Application code will be created. You can review the code in JDEveloper.

 

 

Create an Index on Document

Back to List

To be able to search effectively and efficiently through the documents in the PO_PRODUCTS table, you will need to create the index. The Text Wizard generated the sql to run. Perform the following steps:

1.

Before you create the index, you will want to verify that you have the data loaded in the database. Open a DOS prompt and change directory to your textsearch directory and execute the following commands:

sqlplus po/po@orcl.world
select count(*) from po_products;

You should have 6 records. If you do not have 6, you need to make sure that you install and load the PO schema in the prerequisites section of this lesson. Follow the readme instructions to install.

 

2.

Now you can create the index by executing the following command:

@TextSearchApp_createIndex

 

 

Configure HTTP Server to run the JSP Application

Back to List

Before you can run the application you need to make sure that your HTTP server is configured appropriately. Perform the following steps:

1.

Edit the ojsp.conf in notepad. This file is typically found in the <ORACLE_HOME>\Apache\jsp\conf directory. Add the following alias:

Alias /textsearch/ "<9iDS_ORACLE_HOME>\jdev\mywork\textsearch\textsearch/"

Save and close the file.

 

2.

You will need to stop and start your HTTP server for these changes to take effect.

 

 

Run the Text Search JSP Application

Back to List

Now you are ready to test the application. Perform the following steps:

1.

Open your browser and run the following URL:

http://<hostname>:<httpport>/textsearch/TextSearchApp.jsp

 

2.

Enter Oracle in the Search for field and click Search.

You will see the list of documents that contain the word Oracle.

 

3.

To see the actual document, click on the HTML link. Click back to return to the previous page.

 

4.

To see where the word was actually found, click the Highlight link. You will see the word that was searched in red and a hyperlink is created. You could have documents available in the database that could be retrieved when a user clicked on the link. Click back to return to the list of documents.

 

5.

To see a list of the themes in the document, click the Theme link. Click back to return to the list of documents.

 

6.

To see a quick summary of what is contained in the document, click the Gist link.

 

 

Building a Catalog Search Application using the Text Wizard

In order to search for content in the ways this module will describe, you must perform the following steps:

1. Create Another Project in your Workspace
2. Invoke the Catalog Search Wizard
3. Create an Index on Product Name
4. Configure HTTP Server to run the Catalog Search JSP Application
5. Run the Catalog Search JSP Application

 

Add Another Project to Your Workspace

Back to List

Although you can build your application in the same project, for simplicity you will add another project where you will create your catalog search application. Perform the following steps:

1.

Right-click on your textsearch.jws workspace and select New Project.

 

2.

Select the Projects category and the Empty Project item and click OK.

 

4.

change the directory name to catsearch and the file name to catsearch.jpr and click OK.

You will see your new project in the navigator.

 

 

Invoke the Catalog Search Wizard

Back to List

You will invoke the catalog search wizard to create the application. Perform the following steps:

1.

Right-click on your catsearch.jpr application that you just created and select Invoke CatSearch Wizard...

 

2.

At the CatSearch Wizard Welcome window, click Next.

 

4.

Change the Application Name to catsearchApp and click Next.

 

5.

Click Next to use the same connection your created before.

 

6.

select the PO_PRODUCTS table and the PRODUCT_NAME(VARCHAR2) column and click Next.

 

7.

You will want to search for a product that has a particular price. Select the PRICE(NUMBER) and click > to move it to the Selected Column area and click Next.

 

8.

You can set the way the results will be displayed. Click Next to accept the defaults.

 

9.

You will now create the application. Click Finish.

 

10.

Review the code that was generated and save your workspace.

 

 

Create an Index on Product Name

Back to List

To be able to search effectively and efficiently on product name, you will need to create the index. The CatSearch Wizard generated the sql to run. Perform the following steps:

1.

Open a DOS prompt and change directory to your catsearch directory and execute the following commands:

sqlplus po/po@orcl.world
@CatSearchApp_createIndex

 

 

Configure HTTP Server to run the Catalog Search JSP Application

Back to List

Before you can run the application you need to make sure that your HTTP server is configured appropriately. Perform the following steps:

1.

Edit the ojsp.conf in notepad. This file is typically found in the <ORACLE_HOME>\Apache\jsp\conf directory. Add the following alias:

Alias /catsearch/ "<9iDS_ORACLE_HOME>\jdev\mywork\textsearch\catsearch/"

Save and close the file.

 

2.

You will need to stop and start your HTTP server for these changes to take effect.

 

 

Run the Catalog Search JSP Application

Back to List

Now you are ready to test the application. Perform the following steps:

1.

Open your browser and run the following URL:

http://<hostname>:<httpport>/catsearch/catSearchApp.jsp

 

2.

Enter Oracle in the Search for field and < in the PRICE is drop down and 3000 in the value field and click Search.

You will see that you get two records that match this criteria.

 

 

Module Summary

In this module, you should have learned how to:

Invoke the Text Wizard to create and run a Text Search JSP application

Invoke the Catalog Wizard to create and run the Catalog Search JSP Application

Copyright © 2002 Oracle Corporation. All Rights Reserved.

Close Window

E-mail this page
Printer View Printer View
Oracle Is The Information Company About Oracle | Oracle RSS Feeds | Careers | Contact Us | Site Maps | Legal Notices | Terms of Use | Privacy