Top
NetCOBOL V11.0 ISAPI Subroutines User's Guide
FUJITSU Software

6.7 Explanation of the Sample

To explain the sample, the following shows a Web page for invoking the application (ISASTART.htm), Web pages for processing results (ISARPLY1.htm and ISARPLY2.htm) and a COBOL program (ISAMAIN.cob) used in the sample. Note that only a COBOL program with the entry name HttpExtensionProc (ISAMAIN.cob) is shown. The programs with the entry names GetExtensionProc and TerminateExtension (ISAINIT.cob and ISATERM.cob) are omitted because they are the same as the models shown in Chapter 2 "GetExtensionVersion" and "TerminateExtension".

Web page for invoking application (ISASTART.htm)

<HTML>
<HEAD>
  <TITLE>Start screen</TITLE>
</HEAD>

<BODY>
This is a sample which is used COBOL ISAPI subroutine.<BR>
If you confirm the operation, please press "Execute" button.<BR>
If you exit, please close this Browser.<BR>

<FORM METHOD="GET" ACTION="isasmpl1.dll">
  <INPUT TYPE="SUBMIT" NAME="GO" VALUE="Execute">
</FORM>
</BODY>
</HTML>

Web page for processing result (ISARPLY1.htm)

<HTML>
<HEAD>
  <TITLE>First Access Screen</TITLE>
</HEAD>

<BODY>
<FONT COLOR=BLUE>Thank you very much for having the first time</FONT><BR>
If you use continuously, please press "Execute" button.<BR>
If you exit, please close this Browser.<BR>

<FORM METHOD="GET" ACTION="isasmpl1.dll">
  <INPUT TYPE="SUBMIT" NAME="GO" VALUE="Execute">
</FORM>
</BODY>
</HTML>

Web page for processing result (ISARPLY2.htm)

<HTML>
<HEAD>
  <TITLE>Screen since first time</TITLE>
</HEAD>

<BODY>
Current situation is as follows.<BR>
<TABLE BORDER=2>
<TR>
  <TH>Hostname for accessed host</TH>
  <TH>Browser name</TH>
  <TH>Access count</TH>
</TR>
<TR>
  <TD>//COBOL//Hostname//COBOL//</TD>
  <TD>//COBOL//Browser Name//COBOL//</TD>
  <TD>//COBOL//Access count//COBOL//</TD>
</TR>
</TABLE>
<BR>

If you use continuously, please press "Execute" button.<BR>
If you exit, please close this Browser.<BR>
(Caution: When the Browser is closed, the access counter is reset.
 Moreover, the counter value is different when accessed by a different
Browser or by a Browser on another machine.) 

<FORM METHOD="GET ACTION="isasmpl1.dll">
  <INPUT TYPE="SUBMIT" NAME="GO" VALUE="Execute">
</FORM>
</BODY>
</HTML>

COBOL program (ISAMAIN.cob)

000010*----------------------------------------------------------
000020* All Rights Reserved, Copyright(C) FUJITSU LIMITED 1999-2002  *
000030*                                                         *
000040*  Filename: ISAMAIN.cob                                  *
000050*  Abstract: Example for ISAPI subroutine                 *
000060*---------------------------------------------------------*
000070 identification division.
000080 program-id. "HttpExtensionProc".
000090 environment division.
000100 data division.
000110 working-storage section.
000120     copy COBW3.
000130*
000140 01 HTMLFilename                  pic X(64).
000150 01 pathName                      pic X(256).
000160 01 pathSize                      pic 9(05).
000170 01 copyStartPos                  pic 9(05).
000171 01 leftLength                    pic 9(05).
000180 01 AccessCounter                  pic 9(05).
000190*
000200 linkage section.
000210     copy IsapiCtx.
000220*
000230 procedure division with stdcall linkage using ISAPI-CTX-CNT.
000240*
000250 IsapiSample1-Start.
000260*
000270*  Initalize the work area for the ISAPI subroutine
000280     move low-value to COBW3.
000290     move function addr(ISAPI-CTX-CNT) to COBW3-CONTEXT.
000300*
000310*  Initialize the ISAPI subroutine work environment and obtain
000320*  a Web parameter
000330     call "COBW3_INIT" using COBW3.
000340*
000350     move space to pathName.
000360*
000370     move "Your Access Counter" to COBW3-COOKIE-NAME.
000380     call "COBW3_GET_COOKIE" using COBW3.
000390     if program-status not = zero then
000400         move "ISAERROR.htm" to HTMLFilename
000410         perform outputScreenProc
000420     else if COBW3-SEARCH-FLAG-NON then
000430         move 1 to COBW3-COOKIE-VALUE
000440         perform entryAccessCounterProc
000450         move "ISARPLY1.htm" to HTMLFilename
000460         perform outputScreenProc
000470     else
000480         perform outputContinuousScreenProc
000490     end-if.
000500*
000510 Finish-Pos.
000520*
000530*  Release the resources obtained by the ISAPI subroutine
000540     call "COBW3_FREE" using COBW3.
000550*
000560 IsapiSample1-End.
000570     move 1 to program-status.
000580     exit program.
000590*
000600 outputContinuousScreenProc section.
000610*  Registration of various conversion data
000620*  Get the Cookie data for AccessCounter
000630     compute AccessCounter = function NUMVAL(COBW3-COOKIE-VALUE).
000640     add 1 to AccessCounter.
000650     move AccessCounter to COBW3-COOKIE-VALUE.
000660     move zero to COBW3-COOKIE-VALUE-LENGTH.
000670*
000680*  The access counter value is registered in the conversion data.
000690     perform entryAccessCounterProc.
000700     move "Access Count" to COBW3-CNV-NAME.
000710     move AccessCounter to COBW3-CNV-VALUE.
000720     perform entryConversionDataProc.
000730*
000740*  Get and register remote hostname
000750     set COBW3-REMOTE-HOST to true.
000760     call "COBW3_GET_REQUEST_INFO" using COBW3.
000770     if program-status not = zero then
000780         move "ISAERROR.htm" to HTMLFilename
000790         perform outputScreenProc
000800         go to Finish-Pos
000810     end-if.
000820     move "Hostname" to COBW3-CNV-NAME.
000830     move COBW3-REQUEST-INFO to COBW3-CNV-VALUE.
000840     perform entryConversionDataProc.
000850*
000860*  Gett and register Browser name
000870     move "User-Agent" to COBW3-HEADER-NAME.
000880     call "COBW3_RECEIVE_HEADER" using COBW3.
000890     if program-status not = zero then
000900         move "ISAERROR.htm" to HTMLFilename
000910         perform outputScreenProc
000920         go to Finish-Pos
000930     end-if.
000940     move "Browser Name" to COBW3-CNV-NAME.
000950     move COBW3-HEADER-VALUE to COBW3-CNV-VALUE.
000960     perform entryConversionDataProc.
000970*
000980*  Output prototype HTML file
000990     move "ISARPLY2.htm" to HTMLFilename.
001000     perform outputScreenProc.
001010*
001020 outputContinuousScreenProc-End.
001030     exit.
001040*
001050*
001060 entryAccessCounterProc section.
001070*  After the Browser ends, the content of the access counter can be left by setting
001080*  an expiration. However, if the Browser is different, it is not significant
001090     call "COBW3_SET_COOKIE" using COBW3.
001100     if program-status not = zero then
001110         move "ISAERROR.htm" to HTMLFilename
001120         perform outputScreenProc
001130         go to Finish-Pos
001140     end-if.
001150 entryAccessCounterProc-End.
001160     exit.
001170*
001180 entryConversionDataProc section.
001190     call "COBW3_SET_CNV" using COBW3.
001200     if program-status not = zero then
001210         move "ISAERROR.htm" to HTMLFilename
001220         perform outputScreenProc
001230         go to Finish-Pos
001240     end-if.
001250 entryConversionDataProc-End.
001260     exit.
001270*
001280 outputScreenProc section.
001290*  Get the physical path containing your application and
001300*  edit the HTML document name.
001310     if pathName = space then
001320         perform getPhysicalPath
001330     end-if.
001340     move space to COBW3-HTML-FILENAME.
001350     move pathName(1:pathSize) to COBW3-HTML-FILENAME.
001360     compute copyStartPos = pathSize + 1.
001370     move "\" to COBW3-HTML-FILENAME(copyStartPos:1).
001380     compute copyStartPos = copyStartPos + 1.
001381     compute leftLength = 256 - copyStartPos.
001390     move HTMLFilename to COBW3-HTML-FILENAME(copyStartPos:256).
001400*
001410*  Output HTML document
001420     call "COBW3_PUT_HTML" using COBW3.
001430*
001440 outputScreenProc-End.
001450     exit.
001460*
001470 getPhysicalPath section.
001480     move space to pathName.
001490     set COBW3-PHYSICALPATH to true.
001500     call "COBW3_GET_REQUEST_INFO" using COBW3.
001510     if COBW3-STATUS = zero then
001520         move COBW3-REQUEST-INFO to pathName
001530         move COBW3-REQUEST-INFO-LENGTH to pathSize
001540     end-if.
001550*
001560 getPhysicalPath-End.
001570     exit.
001580

This sample does the following processing:

The screen and processing changes as follows:

The following section briefly describes using various functions in this sample and the reasons for using them.