Getting Started with Net.data
- The first requirement is that you have an Apache HTTP server for serving your
Net.data pages. If you already have an Apache HTTP server then it must be configured
to support the Net.data CGI interface.
A basic Apache configuration for Net.data would consist of a location container and a
ScriptAlias directive as follows -
<Location ~ "^/cgi">
Order Allow,Deny
Allow From all
UserID %%SERVER%%
</Location>
ScriptAliasMatch ^/cgi/(.*) /QSYS.LIB/CGIBIN.LIB/DB2WWW.PGM/$
You can find the configuration file for an Apache HTTP server that has a skeleton
setup for serving Net.data pages here Apache config for Net.data
- The cgi string in the Location container means you could request a Net.data page named
mypage with a url like -
http://yourhost/cgi/mypage/macro
It is recommended that you create a separate library for each Net.data configuration,
(you can have multiple). It is common to give this library a name like CGIBIN.
Although any library will suffice, it is recommended that it be reserved for objects
to be used by the HTTP server.
To get started, the only object needed in library CGIBIN (or whatever you called it)
is the program DB2WWW, which is the essential Net.data interface. It is necessary
to duplicate this program from QHTTPSVR/DB2WWW. Check that *PUBLIC has *USE
authority to it.
- The next requirement is to create an INI file for your Net.data configuration.
The content for a basic Net.data INI file described below.
You can view this file at Basic Net.data INI file.
The INI file allows you to specify the path which Net.data should use to locate your
Net.data pages. The INI file is simply a regular source physical file which must reside
in the library that was specified on the ScriptAlias directive. It must have a source
member named DB2WWW. If the name you have chosen for your CGI library is CGIBIN
then the INI file can be created as follows -
CRTSRCPF FILE(CGIBIN/INI) RCDLEN(240) MBR(DB2WWW)
NOTE: RCDLEN(240) is optimal but you can make it longer if you need to
accomodate entries longer than this.
IMPORTANT: Because the HTTP server must have access to the INI file then you
must ensure that the HTTP server user profile, QTMHHTP1 (or *PUBLIC) has
*USE authority to it, otherwise Net.data requests will fail.
The Net.data INI file is free format text. You should insert at least one directive
into the INI file. That is the MACRO_PATH directive which states the path to your
Net.data pages. Let us assume that your Net.data pages will reside in an IFS folder
named mydemo within the /home folder. Therefore you can edit your INI file using
either SEU or EDTF to add the following directive -
MACRO_PATH /home/mydemo
In fact you could append multiple search paths separated with a semi-colon.
At some stage you will probably be wanting to take advantage of the copy source
feature for including code that is commonly used so you should also add a companion
to the MACRO_PATH directive which is the INCLUDE_PATH. It usually set to the same
value -
INCLUDE_PATH /home/mydemo
It should be noted that INI file directives can be changed without having to reboot
the Apache server.
Because Net.data defaults to using SQL naming convention for qualifying file names,
you should also add the following directive -
DTW_SQL_NAMING_MODE SYSTEM_NAMING
This means that you can use the usual forward slash instead of a dot when you want
to specify a qualified name. e.g. MYLIB/MYFILE instead of MYLIB.MFILE
Another directive that proves useful is that which turns off commitment control for
running SQL statements, as this can be troublesome if left on by default.
DTW_SQL_ISOLATION = DTW_SQL_NO_COMMIT
- A full description of all the INI file directives that can be configured can be found
in Chapter 2 of the Net.Data Administration and Programming Guide for OS/400
Now you should be ready to create Net.data pages.
Back to Tutorials Menu