         28 

       Web- 

       :   ,     .   
  ,  ,   -   , 
   .  -   WWW   ,  
   Web-      Internet. 
        ,       
,         (       
),        Internet    
Delphi.     ,      
     Internet-   
,       Web-... 
       .   (server-side extension)   
  IS API,   DLL,   
  ,      . 

     

          Web-  
 WWW-   WWW-,  
 ISAPI-  ,       
      .    
     ,  Web-     . 

         HTML- 

          ,   
WWW-   . 

          

       ,   
WWW-   . 

         

       TLabel  TQuery  HTML-. 

660


      

        WWW-  ,      .  
     ,  ,      . Windows 
NT 4.0 Workstation   Peer Web Service  Internet Explorer (IE). 
IE    WWW-, a Peer Web Server   
ISAPI-^5_    FTP' Gopher. WWW-  
    Internet   .^^^^^ 
        Cljentjmd ServerWinsock 
Socket.1.15,11,3   ^   . 
      ActiveX   
 . 

         Web- 

          Delphi,     
" "  ,   , ,   
 .   . 
       HTTP.   Hypertext Transfer Protocol (  
)        Internet. 
       HTML.   Hypertext Markup Language (  
),  SGML (Standard Generalized Markup Language). 
      . 
       URI  URL. Universal Resource Identifier/Locator ( 
/ ).    - 
  Internet. 
       CGI. Common Gate-way Interface (  )  
  , WWW-   ;  CGI 
    . 
       Win-CGI. Windows- CGI. 
       Web scripting languages.   Web   Java, 
JavaScript, J Script  VBScript,    . 
       ActiveX.   ActiveX    21, " 
  ActiveX". 
       ISAPI.  Internet Server API     
Microsoft Information Server API,       
^ .	"~      ' 
       NSAPI.  Netscape Server API     
  Netscape. 
           API,      
    Netscape    ISAPI. 

    Intranet 

     , ,   Internet,    
  intranet.       
 . 
             
 ,  intranet       
 ,   Internet.     
: intranet   Internet-   , a 
extranet  Internet-   . 

      HTML 

    HTTP  Hypertext Transfer Protocol (  ), 
a HTML  Hypertext Markup Language (  ).  
    ,   ,   
   ,       
  . 
    HTTP    ,    TPC/IP 
(Transmission Control Protocol/Internet Protocol    
 / Internet). HTTP      , 
  TCP/IP.      File Transfer 
/VotocorTJFTP), Post Office Protocol (POP), Simple Mail Transfer Protocol 
(SMTP).  HTTP   ,      


     28.    Web-cepeepa 661 

     .      ,  
    HTML.  HTTP     
 HTML-;    , -  
    . 
    HTML       . 
,    <1>  </1>    
  ,    <>  </>   
 . 
             Web-? 
-,         
   . -,     
 ,       ASCII-. 

       HTTP  HTML 

    -          
,       HTTP  HTML.      ,  
    . 

    HTTP 

       HTTP    
,      .  ,   
,  HTTP  1.0 (     RFC 1945) 
   : 
        GET (   ,    URL); 
        HEAD (      ,  
  GET,    ,   ); 
        POST (      ). HTML 
     HTML    Delphi    . 
  HTML  ,    
, ,   ,      Delphi. 
        HTML    
 HTML-.  WWW-   . 
    ,   ,   ,    
 . 
    , <Hl>welcome to My Home Page</Hl>  ,   
   Welcome to My Home page    ,  
    ,  ,   ..,   ! 
          http://www.w3.org  
 World Wide Web Consortium (W3C). 

    Web-    

        Web-  ,   
      .    
       
  GUI,       
 .  -     . 
    ,    Web-,    
,    .    
 WWW-        
 . ,     Web,  
  ActiveX      . 

    ActiveX 

     ActiveX        HTML. 
      , 
    GUI-  ,  HTML. 

     / Web 

      :   Delphi    
   Web?  Delphi      
 ,  ,      
   WWW-. HTML      
   

    662  VI.   

     ,    Java, JavaScript, JScript  
VBScript  ,   Web-,   
  -   ,     
    . 

    API- 

      NSAPI (Netscape- API-)    ISAPI, 
 Netscape    ISAPI. -,  
  ,         ISAPI. 
      , Borland  DLL-  
ISAPI  NSAPI.      
   !     ' 
     ISAPI        
 W3C,    -T^miiojTojejvryjaaejab  (, 
,     Microsoft  W3C).     ^ 
    ISAPI,      
". ~	~ ~~ 

      

           DLL,  
 ISAPI.      DLL    , 
    New Web Application,    ISAPI/NSAPI 
Dynamic Link Library.     CGI _\/[-1_ . 
        !."~~"""~ 

     Delphi   ISAPI DLL 

    ,     , ISAPI- -  
   Windows.     Delphi,  
  ,        
Windows,    ISAPI,       
Microsoft,  Netscape,         . 
             
Web-.    Delphi  
  DLL, ^<?      . 
,111<.     , 
            
(,          
Web-      - HTTP-). 

     HTML- 

     DLL   ISAPI      
DLL.     . 
    1.     File^New,     New Items, 
  . 28.1. 
    2.      Web Server Application,     . 
     New Web Server Application,   
. 28.2. 
    3.    ISAPI/NSAPI Dynamic Link Library   ,  
    . 
            ISAPI- 
.  ,        
WebModule (. 28.3),      DataModule,.  
         
  .    ,       . 
      ,     DLL,   
,    ISAPI-DLL  WebDispatcher Actjpnltems. 
     WebModule    ,    
   ,     . 
"~  DLL  Web-  ,  
           . 
     ,   
HTML-.	~ "~ 

     28.    Web-cepeepa	663 

       (Actionltem)    Action 
Editor.     ,     . 
           WebModule. 
          WebModule        
  Action Editor. 
    . 28.1.   New Items    Action Editor 
  . 
    1.      Add     Actionltem. 
    2.      Actionltem (WebActionlteml)     
.         Object Inspector. 
    3.       ,  aiStatic. 
    4.      URI,  /HelloWorld    Pathlnf . 
             
,   . 28.4. 

    . 28.2.   New Web Server Application 


    664  VI.   


    . 28.3.    Web-    WebModule 

    . 28.4.   Action Editor    


     28.    Web-cepeepa 665 

     URI  -       
. ,      ,    
    DLL.   . 
    1.       WEBDEMO.DPR ( ISAPI-DLL   
 \VEBDEMO.DLL). 
    2.      ,     Events   
Object Inspector.  ,       
 OnAction.	.-.._. 
    3.            
. Delphi     . 

    procedure TWebModulel.WewbModulelActionsOAction   (Sender:   TObject; 
    Request:   TWebRequest;   Response:   TWebResponce;   var Handled:   
Boolean); begin 
    end; 

    He           
 HTML-         
 Response.    TWebResponce    
  (     Content).  ,  
HTTP-          
?    Delphi ,  ,  
     ;    Response. Content.  
 ,  ,    ,      
 . 
      ,      . 

    procedure  TWebModulel.WewbModulelActionsOAction   (Sender:   TObject; 
    Request:   TWebRequest;   Response:   TWebResponce;   var Handled:   
Boolean); var HTML:   string; begin 
    //       
    //   HTML. 
    HTML     =	'<HTML>'; 
    HTML     =  HTML  +   '<BODY>'; 
    HTML     =  HTML  +   '<Hl>Hello  World Wide  Web</Hl>'; 
    HTML     =  HTML  +   '<P>This   is   an  example  of  a'   + '   static  
HTML page.</P>'; 
    HTML     =  HTML  +   '</BODY>'; 
    HTML     =  HTML   +   '</HTML>; 
    Response.Content   :=  HTML; end; 

    ,   :     Web- 
!  .   ,   ,  
    ,       , 
   . 

       ISAPI-DLL 

       , ISAPI-DLL       
Windows WWW-,    ( ) DLL   
  .     ,   , 
          
    Microsoft Personal We 
    b Server for Windows 95,    scripts.   
          ,  
    ISAPI-DLL.      
 ,  URL    (Actionltem).   
. ,    http://www.server.com,   DLL scripts 
   .  URL    http: //www. 
server.com/scripts/WebDemo.dll/HelloWorld;     . 28.5. 

     HTML- 

      .      
   ,       
        . ,  
       _,  , 
       ,    
 ^^   . ,   
     . ""* """"""*"* 

    666	 VI.   


    . 28.5.   ISAPI-DLL   Microsoft Internet 
Explorer       Actionltem. 

    1.      WebDemo. 
    2.     Action Editor      Actionltem. 
    3.       aiDynamic.   Pathlnf    /DateTime. 
    4.       OnAction  aiDynamics   
     . 

    procedure  TWebModulel.WewbModulelActionslAction   (Sender:   TObject; 
    Request:   TWebRequest;   Response:   TWebResponce;   var  Handled:   
Boolean); var  HTML:   string; begin 
    //          
    //   HTML. 
    HTML     =	'<HTML>'; 
    HTML  = HTML + '<BODY>'; 
    HTML  = HTML + '<:Hl>The current Date and Time is...</Hl>'; 
    HTML  = HTML + DateTimeToStr(Now); 
    HTML  = HTML + '</BODY>'; 
    HTML  = HTML + '</HTML>; 
    Response.Content   :=  HTML; end; 

       DLL,  ,     
    . URL    http: 
//www.server.com/scripts/WebDemo.dll/DateTime;     
  . 28.6. 
           DLL,  ,  
      .    ,    
,          . 
:  ,      . 

    I  1 


     28.    Web-cepeepa 667 


    . 28.6.         


       

         OnAction,   
    .    . 

    procedure TWebModulel.WewbModulelActionslAction   (Sender:   TObject; 
    Request:   TWebRequest;   Response:   TWebResponce;   var  Handled:   
Boolean); var  HTML:   string; begin end; 

          Request.   
   TWebRequest. 

    	 

    Query	   ,     GET_ 
    QueryFields	  Query 
    Content	   ,     POST 
    ContentFields	  Content 

      ,       HTML-. 

     GET  POST 

    GET  POST   ,  HTTP-   
  HTTP-.        
          . 
     ,   GET        
    Internet.    
  ,       URL   
 (?),     =,   
(&) (    ,    (+)), .. URI  
  : http: //www. server, com/search/results. 
dll?key=Delphi&subject= web+server+application. 

    668  VI.   


     HTML- 

       11_    ,   
       ^^^^:   
 URI " ",   .      HTML-  
  ,      
  ( 28.1). 

     28.1. \UDELPHI3\CHP28\FORM01. . Web-     

    <html> 
    <title>Web Server Applications</title> 
    <bodj>> 
    <hl align="center">Web Server Applications</hl> 
    <h2>Parsed HTML File</h2> 
    <p>This example shows how an ISAPI DLL is used to parse a standard HTML 
page and replace TCustomTags with data determined at run time.</p> 
    <p>To see this example, fill out the following form and submit.</p> 
    <hr> 
    <p>This   form uses   the  GET method</p> 
    <form action="../scripts/WebDemo.dll/ParseFile"  methpd="GET"> <p>Name:   
<input  type="text"   size="20"  name="Name"x/p> <p>Address:   <input  
type="text"   size="20"  name="Address"x/p> <p>Phone:   <input   type="text"   
size="20"   name="Phone"></p> <p>E-mail:   <input  type="text"   size="20"   
name="email"x/p> <p><input   type="submit"xinputtype="reset"x/p> </form> 
    <hr> 
    <p>This   form uses   the   POST  method</p> 
    <form  action="../scripts/WebDemo.dll/ParseFile"  method="POST"> <p>Name:  
 <input  type="text"   size="20"  name="Name"x/p> <p>Address:   <input   
type="text"   size="20"  name="Address"X/p> <p>Phone:   <input   type="text"   
size="20"   name="Phone"x/p> <p>E-mail:   <input   type="text"   size="20"   
name="email"x/p> <pxinput  type="submit"xinpu 
    t  type="reset"x/p> </form> 
    </body> </html> 

         .      
 <FORM>  </FORM>.          
  jJiopMbi (<INPUT TYPE = "reset">),    
  (<INPUT TYPE = "submit">).     , 
 ,        <FORM> 
(,      GET,     POST). 
        ,     
    <INPUT TYPE = "text">,     
     ,  ,   .  
        ,  
    URI. 

     TPageProducer 

           Delphi 3    
Internet.  TPageProducer      
HTML-  .     ,    
String,           
    . 

     28.    Web-cepeepa	669 

      ,   ,      
    .   
Thank You  (    ), 
 ,      
 ( 28.2). 

    ;  28.2. \UDELPHI3\CHP28\THANKYOU.HTM.    "Thank You" 

    <html> 
    <head> 
    <title>Thank You</title> 
    </head> 
    <body> 
    <hl>Thank you for filling out our survey.</hl> 
    <h3>The following is a copy of the information that we received.</h3> 
    <table border="0"> <tr> 
    <td>Name:</td> 
    <tdx#Namex/td> </tr> <tr> 
    <td>Address:</td> 
    <tdx#Addressx/td> </tr> <tr> 
    <td>Phone:</td> 
    <tdx#Phonex/td> </tr> <tr> 
    <td>E-mail:</td> 
    <tdx#emailx/td> </tr> </table> 
    <h5>We will be  contacting you shortly.</h5> 
    </body> 
    </html> 

    ,        ,    
,     <#NAME>  <#EMAIL>.   
  TPageProducer,    ,  
   OnHTMLTag    ,     
 ,           
   . 
       Web-,   . 
    1.	  HTML-        . 
    2.	  WebDemo     Delphi,  . 
    3.	    TPageProducer   Internet. 
    4.        HTMLFile    . 
,      ,  . 
    5.     Events        
  OnHTMLTag     (. 28.7). 

    670  VI.   


     

    ,      .      
  ,         ( 
   ). 

    . 28.7.  WebDemo   TPageProducer 

           . 

    procedure TWebModulel.PageProducerlHTMLTag(Sender:   TObject; 
    Tag:   TTag;   const   TagString:   String; TagParams:   TStrings; var 
ReplaceText:   String); var  Data:   TStrings; begin 
    Data   :=  nil; with Request  do begin case MethodType  of 
    mtPost:   Data   := ContentFields; mtGet   :   Data   :=  QueryFields; end; 
    ReplaceText   :=  Data.Values(TagString); end; end; 

    , ,   ,      
 .   ,    Request     
 ,   .      
 Request      MethodType,     
  ^    .  
  MethodType  mtGet,     
-~17" mtPost,    ContentFieltis, 
     ,    TTag  ,    
    .    
 Values.        = 

     28.    Web-cepeepa 671 

       .   ,   
 QueryFields  ContentFields,    . 
    ,   ,     Actionltem  
    .   . 
    1.        Actionltem. 
    2.      aiParseFile      Pathlnf  
 /ParseFile. 
    3.      OnAction   Response. Content   
:= PageProducerl. Content;. 
    4.       DLL    . 
    5.     FormOl .htm  WWW-  ,  
 action    Web-Demo, dll. 
    6.     ThankYou.htm  ,    
PageProducerl .HTMLFile. 
    7.     FormOl. htm   (. 28.8). 

    . 28.8. ,       . 28.9  28.10. 

    8.         . 
     URI   ,    ,  
    . 
      . 
    9.         URI.  ,   
     URI  ,     
, ,   .	"" 

    672  VI.   


    . 28.9.    GET 

    . 28.10.    POST 


     28.    Web-cepeepa 
    673 22  Delphi 3.   


         

    ,     HTML-  ,  
    .      
      .  
 ,       Internet- 
Delphi 3. 
     TDataSetTableProducer     
 HTML-      .  
    TTable, TQuery      
,   Delphi 3. 
     TQueryTableProducer    
TDataSetTableProducer ,    ,    
  SQL. 
     ,      .  
     WebDemo. dll. 
    1.	  WebDemo    Delphi 3. 
    2.	    Data Access   TSession 
    . 
    3.	   AutoSessionName  TSession  True. 
    4.	  Internet   TDataSetTableProducer  
   . 
    5.	    TTable   Data Access. 
    6.	  Tablel. Database  DBDEMOS. 
    7.	   Tablel .TableName  CUSTOMER.DB. 
    8.	   TDataSetTableProducer I. DataSet  Tablel. 
    9.	  TDataSetTableProducerl .MaxRows   200. 
      TSession     
   .  ,    DLL    
      . 
     TTable     , a 
TDataSetTableProducer    HTML-.  MaxRows 
    (  200).  
TDataSetTableProducer   ,      
 . 
    1.	      TTable    
Fields Editor. 
    2.	           
Add Fields. 
    3.	  CustNo, Company, City, State  Phone. 
    ,    HTML-,     
  WWW-.   !      ,   
!           Header  Footer 
 TDataSetTableProducer.      TStrings. 
      HTML-  Header  Footer. 

    DataSetTableProducer 1.Header := 
    <html> 
    <head> 
    <title>For Internal Use Only</title> 
    </head> 
    <! Note: You will need to change the image source to reflect the true 
location of the image on your system > 
    <body> 
    <center> 
    <hlxfont  color="#FFOOOO">For  Internal  Use  Only</fontx/hl> 
    <pximg  src="http://localhost/Warning.gif"  width="28"  height="28"x/p> 
    </center> 
    <!--  Header.htm ends  here  --> DataSetTableProducer 1 .Footer := 


    674      VI.   


    <!-- Footer.htm begins here --> 
    <hr> 
    <p>Send any corrections  to 
    <a  href="mailto:jsmith@company.com">John  Smith</a> 
    </body> </html> 
     .    . 
    1.       Actionltem   DLL.   
  Name  aiDataSet. a   Pathlnf   /SfiowTabTe!~~~ 
    2.          OnAction. 

    procedure TWebModulel.WebModulelActions3Action(Sender:   TObject; 
    Request:   TWebRequest;   Response:   TWebResponce; 
    var Handled:   Boolean); begin 
    with  DataSetTableProducerl  do begin 
    //   . 
    Caption   :=   '<Hl>Phone   List</Hl>'; 
    //     . 
    CaptionAlignment   :=  ; 
    // . 
    DataSet.Open; 
    //    . 
    Response.Content   :=  DataSetTableProducerl.Content; 
    //   . 
    DataSet.Close; end; end; 

    3.     (warning, gif)      
   Header,      . 
    4.    DLL (. 28.11),      . 

        TQueryTableProducer 

     TQueryTableProducer        
  SQL-    TParams.   
    TQuery   DLL,    
TQueryTableProducer    (. 28.12).    . 
    1.	   WebModule   TQuery   
Data Access. 
    2.	   DatabaseName  DBDEMOS. 
    3.	  SQL   . 
    SELECT  MASTER."SYMBOL"   AS   Symbol,   MASTER,"RCMNDATION"  AS   
Recommend, <b      INDUSTRY."IND_NAME"   AS   Industry 
    FROM   "MASTER.DBF"   MASTER,    "INDUSTRY.DBF"   INDUSTRY WHERE    
(MASTER.INDUSTRY=INDUSTRY.IND_CODE)   AND ((MASTER."RISK"   =:   Risk)   AND   
(MASTER."RATING"   =:   Rate)} ORDER  BY   INDUSTRY."IND_NAME" 
    4.	  Rate  Risk    strings. 
    5.	   WebModule   Internet  TQueryTableProducer. 
    6.	    Query  Queryl. 
    7.      RowAttributes .Align  haCenter,  
      . 
    8.      TableAttributes . Border  1,  
   . 

     28.    Web-	675 


    . 28.11.         

    . 28.12.    


    676  VI.   

    ,     TQuery,    
     SQL-   
TQueryTableProducer (. 28.13)  ,    
     . 
            Actionltem  
 aiQueryTable   Pathlnf  /Query. 

    . 28.13.  WebDemo   TQueryTableProducer 

     ,   TDataSetTableProducer,  TQueryTableProducer  
 Header  Footer.       
 . 

    procedure  TWebModulel.WebModuleActions4Action(Sender:   TObject; Request: 
  TWebRequest;   Response:   TWebResponce; var Handled:   Boolean); begin 
    with  QueryTableProducerl   do  begin 
    Caption   :=   'Stock  Recommendations'; 
    Header.Add('<HTML>'); 
    Heade r.Add('<BODY>'); 
    Footer.Add('</BODY>'); 
    Footer.Add('</HTML>'); 
    // . 
    Query   :=  Queryl; 
    // . 
    Query.Open; 
    // . 
    Response.Content := QueryTableProducerl.Content; 
    // . 
    Query.Close; end; end; 


     28.    Web- 677 

      ,     ,    
     (Internet Explorer 3.x  
).       
   OnFormatCell. 

    procedure  TWebModulel.QueryTableProducerlFormatCell ( 
    Sender:   TObject; CellRow,   CellColumn:   Integer; var  BgColor:   
THTMLBgColor; var  Align:   THTMLAlign; var  VAlign:   THTMLVAlign; var 
CustomAttrs,   CellData:   String); 
    begin 
    if		CellData =	'BUY'	then	BgColor	:= 'Green' 
    else	if	CellData =	'SELL'	then	BgColor	:= 'Red' 
    else	if	CellData =	'HOLD'	then	BgColor	:= 'White' 
    end; 

         ,  , ,   . 
             28.3. 
     ,   . 28.14 
 28.15.       . 

     28.3. /UDELPHI3/CHP28/FORM02. .    
 aiQueryTable 

    <html> 
    <head> 
    <title>Web Server Applications</title> 
    </head> 
    <body bgcolor="#FFFFFF"> 
    <hl align="center">Web Server Applications</hl> 
    <h2>Show Table From Query</h2> 
    <p>This example shows how an ISAPI DLL is used to return a standard HTML 
page containing a table based on a Query.</p> <form 
action="../scripts/WebDemo.dll/Query" method="POST"> 
    <p>Rate: <'s"e^TeTt~"n^fe'e="1rRate'r''srze=wT'1*5'' \     
<option>A</option> I     <option>B</option> |     <option>C</option> ! </selectx/p> 
    '*' <p>Risk: <select name="Risk" size="l"> <option>LOW</option> 
<option>MED</option> <option>HIGH</option> </selectx/p> 
    <pxinput type="submit"xinput type="reset"x/p> </form> 
    </body> </html> 


    678	 VI.   


    . 28.14.  Form02. htm     

    . 28.15.   ,   . 28.14 


     28.    Web-cepeepa 679 


     

    ,     ISAPI-DLL  Delphi 3    , 
  . ,      ,   
     HTML- . 
      ,      -  
             . 
    ,      ,     
 Web-. , ,  Delphi 3,    
    ,    
   Delphi. 

    680  VI.   
