Before start debugging, make sure that user profiles   
    QTMHHTTP and
    QTMHHTP1 
are enabled.
1- Setup
HTTP server jobs do not bump out,
they record CGI programs failures in their joblogs. 
So, first of all, they must have a readable joblog
- before OS/400 release V4r3m0
 
      chgjobd qtcp/qtmhhttp log(4 00 *seclvl) +
        inqmsgrpy(*dft) 
    from OS/400 release V4r3m0 on 
      chgjobd qhttpsvr/qzhbhttp log(4 00 *seclvl) +
        inqmsgrpy(*dft) 
 -   endtcpsvr *http
 -   strtcpsvr *http
  
Second, you must change the "script time-out" value
in your http directives, by specifying a time value
high enough to let you complete your debugs
without having the server job terminating
because of an excessive wait time on the server response.
-   wrkhttpcfg config
 
    add or change the following directive 
      ScriptTimeOut nn mins 
    by specifying af least 30 for nn .
 -   endtcpsvr *http
 -   strtcpsvr *http
  
The third problem,
is to find which HTTP server job detected the failure. 
If you have too many HTTP server jobs,
you will spend too much time in looking at their joblogs.
To reduce the number of HTTP server jobs
(for instance, to a maximum of 3)
 
- endtcpsvr *http
 - chghttpa nbrsvr(3 3)
 - strtcpsvr *http
  
Next, to find out the HTTP server job detecting the failure
 
- if before OS/400 release V4R3M0,
 
      wrkactjob sbs(qsyswrk), 
    otherwise 
      wrkactjob sbs(qhttpsvr)
 - roll up to the http server jobs with a jobname
same as the istance name of the http server you are using
(usually DEFAULT) and press F10
 - run again your failing CGI
 - press F5 to refresh the wrkactjob display
 - display the joblogs of the http server jobs
with a CPU % other than .0
  
 
2- Trivial cases
- If your browser displays
    error 404,
    that may just mean that your HTTP directives are not working
 - If you have installed library cgidev2,
    disable any proxy from your web browser and
    try to run the following:
    
    http://.../cgidev2o/hello.htm
    
    (replace ... with the TCP address of your AS/400)
    
    - If you get no response, but an Error 400 message,
        it may mean that your HTTP server is not serving your request.
        Some of the causes:
        
        - Your HTTP server is not active;
            you can check it by entering command
 
            
            wrkactjob sbs(qhttpsvr)
            
         - Your HTTP server is active, but some other
            active HTTP server is locking port 80
            for its own exclusive use.
            This happens for instance when you also run
            DOMINO.
            You may then try to change the port of your
            HTTP configuration in the following way:
            
            - Assume your HTTP server is DEFAULT
                (controlled by HTTP configuration member
                CONFIG)
            
 - Enter command
    
                
                wrkhttpcfg cfg(config)
                
                to work with your HTTP server configuration
             - Look for a Port
                directive.
            
 - If you find it, change the port number.
                For instance, instead of port 80,
                assign port 7777.
            
 - If you do not find it, just add a directive like
 
                   
                Port 7777
             - Re-start your HTTP server
            
 - Re-try the URL by entering
 
                   
                http://...:7777/cgidev2o/hello.htm
                
              
          
      
 - If you get Error 500 in running
    
    http://.../cgidev2o/hello.htm
    
    do the following:
    
    - make sure that library CGIDEV2 and program CGIDEV2/HELLO1
        are authorized to the *public for *use
    
 - make sure that the configuration directives of
        your HTTP server (command wrkhttpcfg)
        contain the directives needed to run CGIDEV2 CGIs,
        and that this HTTP server was re-started after installing
        such directives (CGIDEV2 directives may be installed through
        command CGIDEV2/HTTPCFG)
    
 - make sure that the configuration directives of
        your HTTP server contain the following directives
 
        
           enable get 
           enable post
        
     - make sure you installed the last available PTF Cumulative
        for product 5769DG1 (IBM HTTP Server for AS/400)
    
  
 - If none of the above solved your problem,
    you may want to restart your HTTP server
    telling to maintain a "very verbose" trace:
    
    STRTCPSVR SERVER(*HTTP) HTTPSVR(DEFAULT '-vv')
    Then
    look at the trace spool files (QPZHBTRC) generated by the -vv trace.
    You can find them by entering command
    
    WRKSPLF SELECT(QTMHHTTP) 
  
Note 1.
Troubleshooting information for CGI is in manual
 HTTP Server for AS/400 Web Programming Guide, Chapter 10.
 Note 2.Information about PTFs can be fount at
 http://as400service.rochester.ibm.com/
 
3- Non trivial cases
This is the most common situation. 
You got to the point where you have really to debug your CGI program.
  
To perform debug, you must have compiled your ILE modules
with the option
        DBGVIEW(*SOURCE)
If you have done so,
 
- strsrvjob ..... the http server job which detected
    the failure
 - strdbg your_CGI_program updprod(*yes)
 - Some basics, when the source of the initial module
    is displayed
    
    - on the command line,
 
        F string 
        to find a string
     - F16 to find next
    
 - move a cursor to a source line and press F6
        to add a breakpoint
    
  
 - Rerun your CGI program.
 
    Hopefully it will stop at some breakpoint of yours,
    you may tell from your debug session
 - More hints on debug
    
    - position the cursor on a variable
        and press F11 to display its value
    
 - you can do the same on the command line by entering
 
        eval variable_name
     - to change the value of a variable, on the command line enter
        
        - eval variable_name = 'value'
 
        if it is a character variable
         - eval variable_name = value
 
        if it is a numeric variable
          
     - to execute one step of coding, press F10
    
 - to resume execution till the next breakpoint, press F12
    
 - if your module calls another module, and you want
        to debug this latter one
        
        - add a breakpoint on the call statement
        
 - when execution stops on this statement,
            press F22 to display and add breakpoints
            to this latter module
        
  
      
  
By sure you will become the most proficient debugger
   in your neighbourhood!
 |