Oracle on the Web Part 1 - Exploring Oracle's HTTP Server

Wednesday Apr 13th 2005 by Steve Callan

Hidden away in the depths of your Oracle installation is a valuable resource you can use to get a jump-start on learning how to combine Oracle's strength as a relational database management system and the power of the Internet. Join Steve Callan as he delves into the Oracle HTTP Server (OHS).

Hidden away in the depths of your Oracle installation is a valuable resource you can use to get a jump-start on learning how to combine Oracle's strength as a relational database management system and the power of the Internet. This resource is extremely easy to visit and requires virtually little in the way of installation and configuration. Even better, what you see and learn in the comfort of your home at your PC (or wherever you are reading this) is immediately extensible to the Internet. This resource is known as the Oracle HTTP Server (OHS).

What does it take to get OHS? Using Oracle9i as a model, it takes nothing more than installing Oracle itself. What does it take to start the server? On Windows, simply start the HTTP Server service, and then viewing Web pages is as simple as entering a URL in your browser. Like many other features within Oracle, the simple starts off fairly simple and the difficult quickly becomes difficult. What I will cover in this article is how to start using what is immediately available based on your Oracle installation, and then make what seems impossible more like it's, well, only next to impossible, but that is still a big difference.

Oracle's Web services are based on the Apache server. In your ORACLE_HOME location, you will see a folder named Apache, and under Apache is another folder (among others) named Apache. It is under this second Apache folder where everything ticks. We need to make a quick stop here before starting the service and viewing the default page in a browser. Open the ports file and note the port number for s_apachePort.

If you are at all familiar with Application Server, that 7778 (and 443 for SSL) should ring a bell, and why not? Application Server's Web services are based on Apache. To start the HTTP Server on your PC, open the Services control panel and look for <the name of your Oracle home>HTTPServer. Start the service.

You can use http://localhost:port_number or http://<host_name>:port_number to see the following page:

It should be readily apparent, if you didn't already realize this, that there are many, many tools and technologies used to present content on the Web, and by no means will you be an expert after reading this article. However, if you have more than a passing interest in using what you know about Oracle and combining it with Web development, reading on will be illuminating. Oracle provides several examples, and we will look at the JSP ones later on.

How to switch the home or default page on your HTTP server

The URL (or URI, depending on your preference for nuances) used earlier only had the host name and port number. Isn't there supposed to be a default or home page? There usually is, and in fact, you want to force users to a home page for two good reasons. First and foremost has to do with security, and the second has to do with control. By control, I mean it is your Web site and your show, so start users off with the main page and then let them navigate from there.

There is a default page and it is specified in a configuration file named httpd.conf in the conf folder. The default page is index.html and this file is found in the htdocs directory. So entering just the host_name:port address or host_name:port/index (or index.html) will result in the same page being displayed. Just for grins and to show how easy it is to change the home page, let's edit the httpd.conf file and set the default page to index.html.fr (all files will be in the htdocs folder). There is an English version (as well as quite a few other foreign language versions) to choose from.

Around line 415, change index.html to index.html.fr.

Stop and restart the HTTP server for the change to take effect, and then refresh the page.

If you have a home network (and this works in your office as well, and it works just as well on UNIX), you can set up your own intranet. Using a second computer (although done on my main computer using remote desktop services), I am able to connect to my HTTP server as shown below. The only difference is that I had to use a "real" IP address or host name instead of localhost.

Let's look at some of the demos which come with OHS. Don't forget to reset your default page to index.html; otherwise you'll have add index.html to the URL to get back to the demo welcome page.

The JServ demo is nothing more than a page showing the following:

The JSP pages/demos have more to offer. Navigate back to the home page and click on the JSP demo's link.

The Basic demo contains several small samples you can view or interact with. The SQL Access demo is of particular interest to us because here is where we get to connect to an Oracle database. Note that you have to provide some connectivity information before using these examples. The jdbc:oracle:thin:@host:port:SID connect identifier is found in other Web servers (e.g., in the web.xml file for Tomcat), so becoming familiar with that syntax will come in handy down the road.

Using the sample5.jsp demo (under the SQL Tags category) and inserting the data several times results in:

In Closing

The Web is rich with tools and resources, and Oracle is rich with database features. It is not uncommon to find many store front Web sites powered by Oracle and the Web pages made more dynamic via the use of JSP (and JavaScript). Understanding how the database interacts with an Oracle-related Web server (think of Application Server and Oracle Applications) makes you a better-rounded DBA or developer and being able to combine the two technologies makes you more versatile with respect to employment. In Part 2, we'll go into more detail about the HTTP server in Oracle10g.

» See All Articles by Columnist Steve Callan

Mobile Site | Full Site