Mark,

When you read the templates in, they'll get converted into whatever codepage 
your program is using and then out to ASCII when you write your output so 
you're not very like to see a performance boost just from that. One place that 
you can see a decent boost is by reading the files in with a large enough 
buffer to get the entire file in memory in one shot which reduces your I/O. One 
thing you'll have to watch out for with this is when your template is bigger 
than your buffer, you have to make sure that you don't write incomplete lines 
out or you'll mess up your HTML.

I typically store my page templates in the root file system just because it's 
easier for me to maintain them. I was long past using libraries for HTML when I 
started doing this so I don't know first hand what difference there is.

Anyway, here's the code I use to spit out my templates (in my case, I don't do 
any additional parsing, I just write them out):

      *//////////////////////////////////////////////////////////////*
      * (GetSection) Get dynamic sections from HTML files            *
      *//////////////////////////////////////////////////////////////*
     PGetSection       B                   export
      *--------------------------------------------------------------*
     DGetSection       PI            10I 0
     D SiteID                        10A   value
     D SectionName                   20A   value
     D Printable                      1A   value
     D UseAltTemplate                 1A   value

     DRC               S             10I 0
     DFileNam          S           1000A
     DFileNamP         S               *   INZ(%ADDR(FileNam))
     DFileDescr        S             10I 0
     DO_CREAT          S             10I 0 INZ(8)
     DO_RDWR           S             10I 0 INZ(4)
     DO_RDONLY         S             10I 0 INZ(1)
     DO_TEXTDATA       S             10I 0 INZ(16777216)
     DO_CODEPAGE       S             10I 0 INZ(8388608)
     Doflag            S             10I 0 INZ(0)
     Domode            S             10U 0 INZ(438)
     Dcp               S             10U 0 INZ(819)
     DBuf              S           1024A
     DBufP             S               *   INZ(%ADDR(Buf))
     DBufLen           S             10U 0 INZ(1024)
     DZeroBin          S             50A   INZ(*ALLX'00')
     DRezult           S             10I 0
     DHoldStr          S           1024A
     DCrLfPos          S             10I 0
     DLastCrLfPos      S             10I 0

      * Determine if we are using alternate templates
     C                   If        UseAltTemplate<>'Y'
     C                   eval      FileNam='/tltswebs/b2bstore/custom/'
     C                   else
     C                   eval      FileNam='/tltswebs/b2bstore/custom/alt/'
     C                   EndIf

      * Build remaining path name
     C                   If        Printable<>'Y'
     C                   eval      FileNam=%trim(FileNam)
     C                             + %trim(SiteID) + '/' + %trim(SectionName)
     C                             + '.html' + ZeroBin
     C                   Else
     C                   eval      FileNam=%trim(FileNam)
     C                             + %trim(SiteID) + '/printable.'
     C                             + %trim(SectionName)
     C                             + '.html' + ZeroBin
     C                   EndIf
      * Open the file for read only
     C                   Z-ADD     O_RDONLY      oflag
     C                   ADD       O_TEXTDATA    oflag
     C                   EVAL      FileDescr=open(FileNamP:oflag)
      *
     C                   If        FileDescr <> -1
     C                   eval      HoldStr=*blanks
      * Read until EOF (RC=0)
     C                   eval      RC=-2
     C                   dow       RC <> 0
     C                   eval      Buf=' '
     C                   EVAL      RC=read(FileDescr: BufP: BufLen)

     C                   Select
      * If an error is detected
     C                   When      RC=-1
     C                   eval      RC = perror(FileNamP)
      * If less than 1024 bytes were read
     C                   When      (RC > 0) and (RC < 1024)
     C                   eval      CrLfPos=%scan(x'00':HoldStr)
     C                   If        CrLfPos > 0
     C                   eval      Rezult=WrtOut(%subst(HoldStr:1:CrLfPos-1)
     C                                   +%trim(Buf))
     C                   Else
     C                   eval      Rezult=WrtOut(%trim(HoldStr)+%trim(Buf))
     C                   EndIf
     C                   eval      HoldStr=*blanks
      * If 1024 bytes were read, only write up to the last CR/LF to ensure
      * proper parsing by the client. The remaining data will be written
      * when the next chunk of data is read.
     C                   When      RC = 1024
     C                   eval      CrLfPos=%scan(x'0D25':Buf)
     C                   DoW       CrLfPos <> 0
     C                   eval      LastCrLfPos=CrLfPos
     C                   If        (CrLfPos+2) < 1024
     C                   eval      CrLfPos=%scan(x'0D25':Buf:CrLfPos+2)
     C                   Else
     C                   eval      CrLfPos=0
     C                   EndIf
     C                   EndDo
     C                   If        LastCrLfPos<>1023
     C                   eval      CrLfPos=%scan(x'00':HoldStr)
     C                   If        CrLfPos > 0
     C                   eval      Rezult=WrtOut(%subst(HoldStr:1:CrLfPos-1)
     C                                   +%subst(Buf:1:LastCrLfPos-1))
     C                   Else
     C                   eval      Rezult=WrtOut(%trim(HoldStr)
     C                                   +%subst(Buf:1:LastCrLfPos-1))
     C                   EndIf
     C                   eval      HoldStr=%subst(Buf:LastCrLfPos+2)+x'00'
     C                   Else
     C                   eval      CrLfPos=%scan(x'00':HoldStr)
     C                   If        CrLfPos > 0
     C                   eval      Rezult=WrtOut(%subst(HoldStr:1:CrLfPos-1)
     C                                   +%trim(Buf))
     C                   Else
     C                   eval      Rezult=WrtOut(%trim(HoldStr)+%trim(Buf))
     C                   EndIf
     C                   eval      HoldStr=*blanks
     C                   EndIf
     C                   EndSl

     C                   enddo

      * If there is any data in HoldStr, write it now.
     C                   If        %len(%trim(HoldStr)) > 0
     C                   eval      CrLfPos=%scan(x'00':HoldStr)
     C                   If        CrLfPos > 0
     C                   eval      Rezult=WrtOut(%subst(HoldStr:1:CrLfPos-1))
     C                   Else
     C                   eval      Rezult=WrtOut(%trim(HoldStr))
     C                   EndIf
     C                   EndIf

      * Close the file
     C                   EVAL      RC=close(FileDescr)
     C                   IF        RC=-1
     C                   EVAL      RC = perror(FileNamP)
     C                   ENDIF
     C                   EndIf

     C                   return    FileDescr

     PGetSection       E

      *//////////////////////////////////////////////////////////////*
      * (WrtOut) Write to STDOUT                                     *
      *//////////////////////////////////////////////////////////////*
     P WrtOut          B                   export
      *--------------------------------------------------------------*
     D  WrtOut         PI            10I 0
     D  StdOutDta                  2048A   VALUE

     DQUSEC            DS
     D QUSBPRV                 1      4B 0 INZ(16)
     D QUSBAVL                 5      8B 0
     D QUSEI                   9     15
     D QUSERVED               16     16

     DStdOutLn         S              9B 0

      * Parameter list for the QtmhWrStout API:
     C     STDOUT        PLIST
     C                   PARM                    StdOutDta
     C                   PARM                    StdOutLn
     C                   PARM                    QUSEC
      * Add CRLF charecter to end of data:
     C                   CAT       x'0D25':0     StdOutDta
      * Find the position of the last non-blank charecter:
     C     ' '           CHECKR    StdOutDta     StdOutLn
      * Write it to standard output:
     C                   CALLB     'QtmhWrStout' StdOut                 80

     C                   return                  0

     P WrtOut          E

Matt

-----Original Message-----
From: MWalter@xxxxxxxxxxxxxxx [mailto:MWalter@xxxxxxxxxxxxxxx]
Sent: Monday, January 31, 2005 2:35 PM
To: Web Enabling the AS400 / iSeries
Subject: RE: [WEB400] CSS


Matt,

Thanks for the tip. Would the same overhead be involved in translating the
html template members? In other words, would I get a performance increase
by storing these templates in the IFS, instead of the qsys.lib file system?
I'd like to keep it consistent.

Thanks,

Mark

Mark D. Walter
Senior Programmer/Analyst
CCX, Inc.
mwalter@xxxxxxxxxx
http://www.ccxinc.com


                                                                           
             "Haas, Matt"                                                  
             <Matt.Haas@thomso                                             
             n.com>                                                     To 
             Sent by:                  "Web Enabling the AS400 / iSeries"  
             web400-bounces@mi         <web400@xxxxxxxxxxxx>               
             drange.com                                                 cc 
                                                                           
                                                                   Subject 
             01/31/2005 02:15          RE: [WEB400] CSS                    
             PM                                                            
                                                                           
                                                                           
             Please respond to                                             
             Web Enabling the                                              
              AS400 / iSeries                                              
             <web400@midrange.                                             
                   com>                                                    
                                                                           
                                                                           




Mark,

Can you access your CSS files by URL in you browser? The fact that you're
using CGIDEV2 doesn't matter since it's the browser that actually requests
them (unless you're embedding the files in the HTML which just slows
everything down). If you're using the Apache based server, the error log
will tell you the location where it's looking for the CSS file.

Generally speaking, you'll get better performance if this file is in the
root file system and is stored as an ASCII text file. Under this condition,
OS/400 is able to send the file right from disk (or memory if you have
caching turned on and this file's in the cache) and out over the network
(this works under both HTTP servers). When you store in the libraries, the
file has to be read in a record at a time, converted to ASCII (unless your
file's there already), and then sent out over the network. There's a lot
more system code involved in this (not not mention CPU usage) and a lot
more disk IO (especially if the file isn't cached already). I don't know
how noticeable this is on newer hardware but the difference between the
libraries and root file system was dramatic when we were using a 50S for a
web server.

Matt

-----Original Message-----
From: MWalter@xxxxxxxxxxxxxxx [mailto:MWalter@xxxxxxxxxxxxxxx]
Sent: Monday, January 31, 2005 1:55 PM
To: Web Enabling the AS400 / iSeries
Subject: [WEB400] CSS


Has anyone been able to use CSS sheets that are stored as Qsys.lib members
with CGIDEV2?

Thanks,

Mark

Mark D. Walter
Senior Programmer/Analyst
CCX, Inc.
mwalter@xxxxxxxxxx
http://www.ccxinc.com

_______________________________________________
This is the Web Enabling the AS400 / iSeries (WEB400) mailing list
To post a message email: WEB400@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/web400
or email: WEB400-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/web400.



_______________________________________________
This is the Web Enabling the AS400 / iSeries (WEB400) mailing list
To post a message email: WEB400@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/web400
or email: WEB400-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/web400.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.