Previous Scenario: Under the Hood


HTML

As far as the HTML document and HTTP server interaction goes, there is nothing out of the ordinary. This works just like all the rest of web servers and clients on the internet.


IDC/HTX

What is more than just an HTML document, though, is our use of Microsoft's Internet Database Connector component of the Internet Information Server and ODBC (Open Database Conectivity). The Internet Database Connector uses the IDC/HTX (Internet Database Connector/HTML Extension) file format which allows us to retrieve data from ODBC data sources and then show the retrieved data formatted in an HTML document on the web. The IDC/HTX file format uses two files, one with the extension .idc and the other with the extension .htx. The .idc file contains information about what ODBC data source to use, what .htx template file to use to merge the database query results into an HTML document, a SQL statement, and sometimes a username and password for accessing the ODBC data source. An example of this .idc file would be this example.idc file: Note that the Username and Password fields are not needed if you have not setup a username and password on the ODBC data source you specify.
The second needed file is the HTML extension file you specified in the Template field of the example.idc file. The example.htx file might look something like this: The Important part of this file is the three lines starting with the <%BeginDetail%> directive and ending with the <%EndDetail%> directive. What happens is that after the query from the example.idc file has been made, the Internet Database Connector takes this example.htx file and for every record, inserts the correct data for the specified field into the HTML code contained within the BeginDetail and EndDetail segment. In this case, the value of the field named lastName and the value for the field named firstName are inserted into the <%lastName%> and <%firstName%> placeholders respectively. Having performed this merge of data and template, the server now returns the final HTML document to the web browser for viewing as an HTML page.


ODBC

ODBC as stated earlier stands for Open Database Connectivity. It attempts to provide a common interface for talking to databases. ODBC has many database drivers that let it talk to different databases, but you don't have to worry about that. You just write your queries according to the ODBC interface and then ODBC worries about translating your ODBC query into a query that is specific to whatever database your DSN points to. So, in theory, you can write you query for ODBC and have it work for many databases without changing anything. If you should decide to migrate you current database to a different database, that is no problem since you are only talking to ODBC and ODBC handles talking to databases. Simply set your ODBC DSN to point to your new database and everything should work just as before.


JavaScript

We didn't use much JavaScript at all. We only used it in two places. The first use is a trivial one in which we used it to display a simple message in the status portion of the web browser window. A simple example of what we did is: So, when you move your mouse over the Click Me link, the string "Click me!" will appear in the status portion of the web browser window. As you can see from this example, it just uses the JavaScript onMouseOver event handler to display the status message when the user moves the mouse cursor over the link.

The second place we used JavaScript was in a much more interesting way. We used JavaScript in the Caterpillar Sponsored Research pages of each Caterpillar partner university. The actual file name is projects.htx. The JavaScript code used is as follows: The problem we came accross was that we wanted to do a second query based on the results returned from the database from the first query, but often what was returned was a string with spaces. When we would try to pass this string as part of a name/value pair in the URL, it would not work because of the spaces. We needed a way to format the string so that in place of spaces, we would have the + character which URL parsers understand to represent a space when decoding the URL. JavaScript is one solution to this problem. When the user clicks on the link of project name, the first function send(projectNameString, siteNameString) is called with the project name string and the site name string (university). This function then calls the second function above called formatString(aString) which takes a string and puts a + character in place of a space character. It returns the resultant string containing no spaces. The send(projectNameString, siteNameString) function then finishes execution by opening the new document returned by the new query.