     6 

     

    Java,    ,  , , 
- ,      .  
     ? ,    
-  ,   . 
, Visual Basic   -,    
 ,   - Java ( VB-  
     ).     
 Java   ? 
    ,         
 .      ,   
  Internet    WWW-.   
 Internet ,     :    
-  . 
       Java.      
OCX-  Windows  ~ ActiveX.    
1_1- ,   ,   
 Web-  .  , 
           
 .       (, 
             ). 
        ,   Web-,   
    ,     
,       e-mail.  
 ,      ,   Web-, 
 ,       WW.W.  
  ^^  .	~ "~ ~~' ~~~~ 
     ^       
 Java,   Visual J++   ,   
  .       
Applet Wizard,     .   
 AppWizard  Visual C++:  

    177 

      ,      . 
   ,        
 . 
     Visual J++     , 
 .         
"",    ,    ,    , 
  ,  ,     Visual J++  
    .     
  Java,         Visual J++, 
    . 

      

      ?  Applet    Java     
java.applet.       import   
      : 

    import java.applet.Applet; 

     

    import java.applet.*; 

     . 6.1 ,     Applet   
.   .      , 
           
. (      4.) ,   
 . 6.1,    Component     
     .   
   Web-,     
 .  . 6.2    ,   
  Internet Explorer. 

    java.lang.Object    j 
    !'. Java.awt.Component j 
    I   Java.awt.Container 1 
    L___..  ^ 
    I    java.applet.Applet   } . 6. l.   Applet    


    178	Visual J++:   


    . 6.2.  Web-    


       

           ,   
     Internet.    
,         . 
     ,       WWW- , 
    ,     
  . ,     ,  
        .  
      ,   
   .   ~   
      
.ø ,    WWW-, 
    ,       
  ^     ,   
  ,       , 
    ? 
    , .          
.          

     6.  179 

.  ,       
Web-. ,         
  URL       . 
 ,      ,   
     . 
         ,     
.    Java-,      
   Java, ..     
 ,    .    
    ,       . 
             
    .    
   ,   . * 

       WWW- 

        WWW-   <-PLETX  
Visual J++   ,   HTML-,     
     <APPLET>. , HTML-    
   Animation,    Samples/Sun 
Samples/Animation Applet.   <-PLET>   : 

    Opplet code=Animator.class width=460 height=160> 
    <param name=imagesource value="images/Beans"> 
    <param name=backgroundcolor value="OxcOcOcO"> 
    <param name=endimage value=10> 
    <param name=soundsource value="audio"> 
    <param name=soundtrack value=spacemusic.au> 
    <param name=sounds value="l.au|2.au|3.au|4.au|5.au|6.au|7.au|8.au|9.au|0.au"> 
    <param name=pause value=200> </applet> 

     HTML-    ,    
<APPLET>    </APPLET>.    <APPLET>   
: Code, Width  Height.   Code   ,   
;  Width  Height    ,  
     WWW-. 
    I^e^Code ,      Animator.   
Code "Animator.class"    -,    ^ 
     -, __^  . 
        Code    
"Animator.class"  "Animator". 
      Width  Height     ( ) 
,    .    

    180	Visual J++:   

    HTML- .         
  WWW-.   Width  Height  , 
    ,      
   WWW-. 
       ,      <APPLET>.  Name  
     WWW-.      
   ,        WWW-. 
       ,  getAppletQ  
AppletContext     _ .  _1^ 
,        ,  
,      ^'1711~  
      WWW-. 

        

        <APPLET>   Codebase ( 
 ).   ,      
.         - 
    ,        
WWW-. ,  WWW- "www.myser-ver.com",  URL 
"http://www.myserver. com/MyAppletPage.html.",  WWW-,  
.  <APPLET>   : 

    <APPLET CODE=MyApplet WIDTH=100 HEIGHT=200> </APPLET> 

         MyApplet  ,   
 URL "http://www.myserver.com/MyApplet.class".    
 URL WWW-   - ("MyApplet.class").   
     WWW-,     
, ,   : 

    ClassNotFoundException: class MyApplet not found. 

    ,   URL      URL HTML-. 
 - ("MyApplet.class")     IJRL, 
   URL .  . 6.3    
 -  WWW. 

     6. 	181 


    |c:.\webfilcs 
    MyApplet.class 
      MyApplet 
    WWW-  

    . 6.3.   -  WWW 

     <CODEBASE>      
- .    ,    
    <APPLET>: 

    <APPLET CODE=MyApplet CODEBASE="/java/classflies/" 
    WIDTH=100 HEIGHT=200> </APPLET> 

    ,     <APPLET>,    
MyApplet.class    "http://www.myserver.com/MyApplet.class",   
 "http://www.myserver.com/java/classfiles/MyApplet.class".   
URL,            
 -.  . 6.4 ,     
HTML-,       -   
-  WWW. 
             
 .        
-    ,      , 
      <APPLET>    .  
     WWW-,  WWW-  
,       -. 
     ,     -    
     ,    . 
,   MyApplet      MyPanel, 
      -  MyPanel.   
     ,   - .  URL  
MyApplet.class   
"http://www.myserver.com/java./classfiles/My-Applet.class",   - 
MyPanel.class   URL "http://www.myserver.eom/java./classfiles/MyPanel.class". 


    182 Visual J++:   


    'www.server.com 
     -   common code     
    hltp://www.server.com/samplc/Si-imple.litnil    1 
      MyAppIet   <CODEBASE>,   !' 
/common code 
    WWW-  

    . 6.4.       - 


      

      -,   ,    URL 
  HTTP-.     20- ,   
  ,     20   
HTTP-.   ,    HTTP-  Internet  
 ,        
    -.      
   . 
     ,     () - 
 .  ,    -    50%, 
  PKZIP  -  . 
      20-        
       (,  , 
  )    . 
           (   ) 
.    Visual J++    
-,      WWW. _, 
  Internet Explorer 3.0   . - 
  . 
        Java  1.1.   Java  
   JAR- ("Java ARchive").   - 
   Java 1.1,        
.   JAR    WWW- JavaSoft.  
 JavaSoft    "http://www.javasoft.com". 
    -  JAR-       , 
     .   

     6.  183 

   -       
.        .  . 6.5 ,  
    . 

     
     - 
       
      
      

    . 6.5.   


      -  JAR-    .  
-  -  Microsoft (""  cabinet), 
      .    
        - 
(Lev-Zimpel). (      PKZIP.)  
JAR-    ,    ZLIB. 
         . 
,      , -  JAR-   . 
     -     (   
)    ,     
 -.        
   Java        
WWW-.     -  ,  
   ,   -.    
 ,     .   ,  
   . 

     - 

    1:^>        .   
     Java  1.1,     
5)*{ JAR-. 
        Internet Explorer       
-.   Visual J++  1.1     
,    -.     
   CAB Wizard,      
-   . 

    184 Visual J++:   

       -   Visual J++.  
    - Visual J++   
 CABDEVKIT.EXE,    CABS&SIGN.  ,  
 Visual J++     . 
         -    
OVERVIEW.HTM,    CAB&SIGN -.   
      -  , 
  Visual J++.          
-,      (Ǹ "signing). 
      
         Java-,   
WWW-.     initQ, start(), stopQ  destroyQ, 
  main() Java-.   -   
   . 
            
mainQ    astrArgsf]  String.      
,       .    
HTML-.    ? 
           <APPLET>   <PARAM>. 
    <PARAM>      Applet, 
  HTML-. 
      <APPLET>  </APPLET>    <PARAM>.  
   .   <PARAM> : 

    <PARAM NAME="paramname" VALUE="paramvalue"> 

     <PARAM>     /,   
 .        . 
,        
,   Animator  Sun   
,           
 .     <PARAM> HTML- 
 Animator: 

    <param  name=imagesource  value="images/Beans"> 
    <param  name=batAgroundcolor  value="OxcOcOcO"> 
    <param name=endimage value=10> 
    <param  nan\ef=soundsource  value="audio"> 
    <param name=^eundtrack value=apacemusic.au> 
    <param name=sounds 
    value="l.au|2.au|3.au|4.au|5.au|6.au|7.au|8.au|9.au|0.au"> 
    <param name=pause value=200> 


     6. 	185 

       <  >  Animator    
  "imagesource",   "images/Beans";    
"backgroundcolor"   "";    "endimage"  
 "10"  . .   Animator   . 
  ,      
,      ,  
     . ,    
 ,       
       ,    
,     ,  
      .      
  ,   ,    
.     Applet  getParameterQ. 
      ,    
  HTML-,    <APPLET>.    
  .    ,   
 null.    ,    URL  
   ,  "URL".	I 

    class MyApplet extends Applet {	i //  ...                                                 I 
    //    URL,   "URL" . public 
URL getURLparam(){ URL url; try { 
    url = new URL(getParameter("URL")) ; } catch (MalformedURLException mue) { 
url = null; 
    return url; 
    i 
    //  . 


          

        ,      
   Applet, : init(), start(), stop()  destroyQ.  
          
 . 

    186	Visual J++:   

     init()   ,    ,  
 ,   .       
  ,        
,      .    
  initQ        . 
     startQ  stopQ      .  
startQ   , <   HTML-, 
 .          
,      HTML-,  
 stopQ.	~7 
     start()  stopQ     . 
,       ,   
   - ,       
   startQ,        stopQ, 
  . 
       ,    " " WWW. 
      ,      
 ,      ,  ,   
   .       
,    ,       
   . 
      startQ  stop() .    startQ 
      stopQ.   startQ 
     initQ     stopQ. 
           destroyQ.   
   ,      . 
   ,      
HTML-     . ,  
   initQ,    destroyQ. ,  
       ,  
      .      
,     :   
,     stopQ (,     
    start()),  ,   
    . 
    "     . .    initQ, 
startQ, stopQ  destroyQ,   . 
     ^   Applet.     
.    ,      
      repaint()    
,   .     
   :  m_threadTimer  Applet 
     , 

     6. 	187 

  .       
,      .   
      . 

    initO { 
     start() { 
     stop() { 
     deestroy() 
     
    N 
    N+l. 
    N+2 

    . 6.6.    init(), startQ, stopO  destroy() 


    import Java.applet.Applet; import java.awt.*; import java.util.*; 
    class TimerApplet extends Applet implements Runnable { // 
Private-     // ,    
. private Thread m_threadTimer; 
    //   init()    Font, 
    //        
    //    . 
    public void init() { 
    Font f = new Font("Helvetica", Font.BOLD I Font.ITALIC, 15). 
    setFont (f); } 
    //   start()    , public void 
start () { 
    * m_threadTimer = new Thread(this); 
    m threadTimer.start(); 
    //   stopO   .  W/  
     (m_threadTimer) /*    
    run()  //      
  // run(). public void stop() { 
    m threadTimer = null; 


    188 Mi. Visual J++:   


    //   destroy()     , //   
    stop  . public void destroy(} ( m threadTimer = null; 
    //   run(),     // , 
  . //     repaint(). 
//   m_threadTimer    //   
  ,  , public void run() ( do { 

    repaint(); try { 
    Thread.currentThreadO .sleep(lOOO); }   catch   (InterruptedException  ie) 
   { 
    System.out.println("Timer  thread was  interrupted:"   +  ie) break; } }   
while(m_threadTimer  ==  Thread.currenthread()); 
    } 
    //      paint  . public void 
paint(Graphics g) { 
    g.setFont(getFont() ) ; 
    FontMetrics fm = g.getFontMetrics(); 
    Date date = new Date(System.currentTimeMillis()); String strTime = "" + 
date.getHours() + ":" + 
    date.getMinutes() + ":" + date.getSeconds(); 
    int ex = fm.stringWidth(strtime); int cy = size().height/2; 
    g.drawstring(strTime, ex, cy); 


     Applet Wizard 

          Visual J++   Applet 
Wizard.        ,  
   .  Applet Wizard    
      *!*?5-, 
    ,      
         ,  
    . Applet Wizard  
,            
   .       Visual J++. 

     6. 	189 

         Applet Wizard     
  Developer's Studio.   ,   New...   
File  ,    Project Workspace    New. 
    New    Project Workspace. 
                
.     ,    
   Visual J++,    . 
            New Project.  
    Applet Wizard       
  Applet Wizard.   Name   ,  
 ,   Location  ,     
 .    ,     
  New Project Workspace,    
"AppletWizExample"   "C:\MSDEV\Projects\AppletWizExample". 


    190 Visual J++:   


      Applet Wizard    Create    
New Project Workspace.       ,  
       . 
       ,  "Java Applet Wizard  Step 1 of 5", 
   .      
  Applet Wizard. 
                   ,      
 . 
        "How would you like to be able to run your program?"  "  
   ?"    .   
,    ,       ,   
   Java    .   
            
   AppletContext (  ).     
     ,  showStatusQ  
showDocumentQ.   ,     ,   
        . 
        "What would you like to name your Applet class?"  "   
  -?"       
  ,       . 
        "Would you like to generate source file comments?"  "  , 
      ?"     
,   Applet Wizard   

     6.  191 

      .    Explanatory Comments  
 ,       
 .    TODO Comments     
 , ,       
 Applet,  Applet Wizard. ,  initQ   
 : 

    // TODO:    . 

              
Next,      .     
  Back,       
 . 
        Applet Wizard   HTML-, 
         Visual J++. 
   "Would you like a sample HTML file?"   "Yes, please", 
    HTML-,      . 
  HTML-        HTML.  
      ,     
  . 
        Applet Wizard  HTML-   
    .      
320x240 .  ,       ,  
    Width  Height  <APPLET>  HTML-.  
      HTML-  
.         
 Next. 

    192 Visual J++:   

        Applet Wizard    : 
             ,   ,  
      ? 
             ,    ,  
      ? 
        ,  Applet Wizard  
 Applet, j)e^H3yro^HJL jmjjjp^^ 
       .   run()  
 '' repaintO/sleepO,"     50 
.     (),      
  : 

    public void run() { 
    while (true) 
    { 
    try 
    { 
    repaint(); 
    Thread.sleep(50); ) 
    catch (InterruptedException e) { 
    //  InterruptedException   
    // Thread.sleep().  ,    
    / / "" . 
    Stop(); 
    } 

             
,  Applet Wizard    runQ    
  .    
     repaint()/sleep().  
  repaint()/sleep()     . 
  Applet Wizard     
,    ,  , 18 
    GIF.   ,   
 .     , 
       . 

     6. 	193 

           ,   
,        .  
     "mouseUpO, mouseDown()"   
   mouseUpO  mouseDownQ,    
,       . ,  
  mouseMove(), mouseDragQ       
,           
""  .   mouseEnter()  mouseExitQ 
,         
   .       Java 
   4. 
        Applet Wizard,    
,  ,    . 

    194 Visual J++:   

         : 

          

    Name	   ,    Name  <PARAM> HTML-. 
    Member	 ,     . 
,  Applet Wizard,    
  . 
    	 .       
  : ,  ,   , 
,   .      true  false. 
    ,      URL,  
   String    ,  Applet Wizard." 
    Def-Value	 , ,     *   
      ,         HTML-       <PARAM>. 
    Description        ^-     
getParameterlnfo() (   ),   
 Applet  ,        
.         
 (: "number of prime numbers to generate; 0-10"). 
    Applet Wizard          ,   
    .    

     6.  195 

        ,       
 ^  : 

    jview MyAppletClass paraml=vall  param2="va!2  with  spaces" param3=number 
        : 
    |Name: AppletWizExample 
    _ : Brian Miso 
    (Created with Microsoft Visual J++ Version 1,0| 
    i. fiacK 
    Finish 
    Cancel 

          ,   
getAppletlnfoQ .  ,   public,   
    ,      
Java.       ,   , 
     ..   Applet Wizard  : 

    Created with Microsoft Visual  J++ Version   1.0 

          Microsoft,    
Appletlnfo  . 
      ,     Finish. Applet Wizard 
      ,   ^   
ClassView.     .     
. ,      ^ 
.  ,  Applet Wizard   ,  
,          . 
  .      , 
,     .  ! 

    196 Visual J++:   


     Applet 

           ,   
  : initQ, startQ, stopQ  destroyQ.   Applet 
    ,      . 

         

        ,      
 . ,     Applet,  
 , ,        . 
      ,         
         
 ,    getApplet-Info()   
  Applet.       ,   
 , URL WWW-,      
 ,        
. , Applet Wizard no    getAppJetlnfoQ,  
      : 

    "Name: <Applet class name>\r\n" + 
    "Author: <your name here>\r\n" + 
    "Created with Microsoft Visual J++ Version 1.0"; 

    ,           
  -       Visual J++. 
     getPararneterlnfoO  Applet    
,  ,       . 
  getParameterlnfoQ : 

    public String[][] getParameterlnfo(); 

           
  .       
. ,    .     : 
    {"par^  name",   "parameter  data  type",   "Description"} 
           ,     
 Name  <PARAM> HTML-.      
  (,  int, long  url).     
 .         
.        , 

     6. 	197 

         
      . ,   
   "numFrames",       1  100: 

    {"numFrames", "int", "Number of animation frames: 1-100") 
      getParameterlnfoQ   : 
    private static String!][] m_aastrParamInf = ( 
    {"numFrames", "int", "Number of animation frames: 1-100"} {"backcolor", "OxOOrrggbb", 
    "Backgroundcolor to use: in packed red/green/blue 
    hex format"}, 
    {"imageBaseName", "string", '	"Base to use for generating image filenames" + 
    ": <basename>00.gif is used for first image") }; 
    public String[][] getParameterlnfo() { 
    return m_aastrParamInfo; } 


      5   

         .    
   Applet    AppletContext. 
           
  .      AppletContext  
,  ,      Internet.  
       ,    
showStatusQ  AppletContext. 

        

      ,      , 
  , ,      
  Internet  -  ,    
WWW-.   .       
 Internet      . 
     getlmageO  Applet      
URL.    ,    
 ,    URL. (    
  AppletContextgetImage(),     
AppletContext  .)   ,    
  ,        Image.  
         -   
  . 

    198	Visual J++:   

      getlmageQ   URL,    
   . 
      getlmageQ  getAudioClipQ    
  Internet. (,      
       AU,   8   
,   u-Law.    ,   ,   
    ,   -  
  , 1- Gold Wave.    
    p6Wsiwft^op_M?r_WAV, 
   Windows,   AU*   Java  
.  getAudioClipQ  Applet    
getAudioClip()  AppletContext. 
      Java    AudioClip.   
AudioClip     play(), stop()  1(),   
  ,      
 . 
      Applet    ,    
   AudioClip.  playQ  Applet  URL  
  ,    URL .   
    AudioClip   LJRL    playQ. 

      

     getParameterQ  Applet     
  .     ,    
 <PARAM> HTML-.  GetParameterQ     
     .      , 
  null. 

     getDocumentBaseO n getCodeBaseQ 

     getDocumentBaseQ  URL  HTML-,    
.    ,    ^ 
 ,    . ,    
   "img0001.gif   "images"  ,  
  HTML-,     : 
    
    Image img = getIMage(new URL(getDocumentBase(),"images/imgOOOl.gif")); 

     URL        URL 
 "images/imgOOO I .gif. 
        Applet    URL,    
 getCodeBaseQ,     HTML- ,     
     ,   .   
     ,     
 ,   getDocumentBaseQ    getCodeBaseQ. 

     6. 	199 


      AppletContext 

      AppletContext    ,    
.        
        . 
          AppletContext   
 getAppletContextQ.       Applet, 
  private,       AppletContext 
     . 
     showStatusQ  AppletContext      
  . (  ,      
AppletContext  .)      
   : 

    getAppletContext () .showStatus("Attempting to download files."); 

          HTML-.  
showDocumentO  AppletContext  URL,    
 ,      .  
   ,      
String, ^_  Frame,     
HTML-. (,      ,    
   .        
.)        Frame,   
<FRAMESET>.           HTML-. 

        

        AppletContext       
,    .     
,      HTML-. ,  
 -,       . 
      getApplet ()  AppletContext  , 
   Name   (   <APPLET>  
HTML-  ).      ,  
    ,    ,   
 .  instanceof       
  . 
        Name  <APPLET>.   .  
 AppletContext  ,  getAppletsQ. '  
  ,     ,  
    .    ,   
      ,    ,  
    : 

    import Java.applet.Applet; import java.awt.*; 


    2OO	Visual J++:   


    import Java.util.*; 
    class CooperativeApplet extends Applet { 
    //       CooperativeApplet, //  
 " 
    private Vector m_vectOtherApplets = new Vector(); 
    //  addRef()  removeRefO    //   
   // CooperativeApplet. 
    public void addRef(CooperativeApplet a) { if(!m_vectOtherApplets.contains(a)) 
    m__vectOtherApplets . addElement (a) ; } 
    public void removeRef(CooperativeApplet a) ( if(m_vectOtherApplets.contains(a)) 
    m_vectOtherApplets.removeElement(a); 
    //  init()         //   
   . public void init() { 
    Enumeration enumApplets = getAppletContext().getApplets() 
while(enumApplets.hasMoreElements()) { try i 
    CooperativeApplet a = 
    (CooperativeApplet)enumApplets.nextElement(); 
    m_vectOtherApplets.addElement(a); a.addRef(this); } catch 
(ClassCastException cce) { 
    //  - ,     //   
CooperativeApplet.  // ,   . 
    //    .   
    // CoopetativeApplet     . 
    public void destroy() { 
    Enumeration enum = m_vectOtherApplets.elements(); 
    while(enum.hasMoreElements()) 
    ((CooperativeApplet)enum.nextElement()).removeRef(this); } } 

             . 
   "  AppletCon-text.getApplets. 

     6. 	21 


    ,       

       ,       
       -, 
    .     
    ""     . 
 ,      Internet,    
     . 
       ,      
  .      WWW-  
,    WWW-.     WWW! 
        ,   , 
   .      
   Java,        WWW 
 .  ,     .  
          ,  
       . 

       

    ,          
   -        
     .       
    ,     . 
        File, FilelnputStream  FileOutputStream  
  (,    )    
,   . ,    
   ,     HTML-: 

    import Java.applet.Applet; import java.awt.*; 
    public'class BadApplet extends Applet { 
    puby.c void init() { try { 
    FilelnputStream in = new FilelnputStream( ***	getParameter ( "f ileToOpen" 
) ) ; ^ } catch (Security-Exception) { 
    System.out.println("SECURITY PROBLEM TRYING TO OPEN 
    FILE!"); ) } ) 


    2O2	Visual J++-.   


        

    ,       
,  SecurityManager.    SecurityManager 
   11. 
       ,    SecurityManager.   
  System    SecurityManager.    
      ,    
.       ,  
 .  
        ,  ,  
 .      ,   
       . 
    _  Java    -: _. 
   ,     ,   
    .     
"" ,      . 
           ,   
""  .      
 ,     "" 
.  ,   Java   . 

        

    ,  Java   ,     .  
  ,        
   . ,   ,  
    .      
      .     
  ,     ,    
  . ,        
 ,    ? 
            ,    
^  ?   !   , 
 ,   IP-     URL, 
*    getDocumentBase().  Internet 
           
.        , 
    ,     
   .    , 
    .  . 6.7 ,    
     ,   ,    . 

     6. 	2 


    () <  >, "bob," <  ...> (6) < 
 >, "bob," <  ...> 
    pTOK-fleifOH,    
     www.server.com 
      
        "bob" 
    '      "bob" 
       
    ɨ8 
       

    . 6.7.          
  

       . 6.7,       
    ,     . 
 WWW-  HTTP     
  .      , 
          
 . 
             
 Internet. ,      , 
        . 
          
    WWW-,    . 
           
^    Internet. __- 
       ^ ".    
 ,   ,   . 
    ,     , 
   . 

    24 Visual J++:   

           ,   
   .       
" ",     ,   
.  ,   ,    
.   ,       
,         : 

    import Java.applet.Applet; import java.awt.*; import java.net.*; import java.io.*; 
    public class MyStoringApplet extends Applet { 
    public static final int m_nStorageServerPort = 1001; 
    //  ... 
    //  saveRemoteData()   ,  
    //      , 
    //   ,    . 
    public void saveRemoteData(String strFilename,byte[] abData, int offset, 
    int length) { 
    //      ,  // .  
m_nStorageServerPort  //   _ ,   . 
 // .         "" 
    DataOutputStream out = null; try { " """ """"  '"' 
    InetAddress addr = InetAddress.getByName( getDocumentBase().getHost()); 
    Socket sock = new Socket(addr, m_nStorageServerPort); 
    out = new DataOutputStream(sock.getOutputStream()); } catch 
(UnknownHostException uhe) { 
    System.out.println("Could not lookup host."); 
    return; } catch (lOException ioe) ( 
    System.out.println("Could not connect back to host."); 
    return; } try { 
    //  " ". 
    out.writelnt(0); 
    ׻ 
    ^i/   ,   
    //  . 
    out.writeUTF(strFilename); 
    //  . 
    out.write(abData, offset, length); 


     6. 	25 


    //   ,   . 
    out.close (); } catch (lOException ioe) { 
    System.out.println("Problem writing data to server:" + ioe), 
    return; } 
    //  getRemoteData()     
    // .   . 
    public byte[] getRemoteData(String strFilename) { 
    //     ,  
    // .  m_nStorageServerPort  
    //     . 
    DataOutputStream out = null; 
    InputStream in = null; 
    try { 
    InetAddress addr = InetAddress.getByName( getDocumentBase () .getHost ()) ; 
    Socket sock = new Socket(addr, m_nStorageServerPort); 
    out = new DataOutputStream(sock.getOutputStream ()); 
    in = sock.getlnputStream(); } catch (UnknownHostException uhe) { 
    System.out.println("Could not lookup host."); 
    return null; } catch (lOException ioe) { 
    System.out.println("Could not connect back to host."), 
    return null; 
    //   " "   . //   
 . ByteArrayOutputStream bytes = new 
ByteArrayOutputStream() try { 
    out.writelnt(l); 
    out.writeUTF(strFilename); 
    int n; 
    while |_true) { 
    n = in . read () ; bytes.write(n); } 
    . } catch (EOFException eof) { } catch (lOException ioe) { 
    System.out.println("Problem reading data from remote server. 4   
finally   { try   { 
    in.close () ; ^4^     } catch (lOException ioe) ( 


    2O6	Visual J++:   


    //  , return bytes.toByteArray(); 

     ,       WWW-, 
    .     
,     " "  " " 
   .   ,    
          , 
^1);_? .    -: 

    import java.net.*; import java.io.*; 
    //    SimpleFileServer   
    //      .   
    //        ServerSocket  
    //     SimpleFileServer 
    //     . 
    public class SimpleFileServer { 
    //  . 
    private static final int m_nServerPort = 1001; 
    //    
    // _ ServerSogket. 
    private static ServerSocket m_socketServer; 
    //  main()   ,   //    
 SimpleFileServer   . public static void main(String 
[] astrArgs) ( //   , try { 
    m_socketServer = new ServerSocket(m_nServerPort); } catch (lOException 
ioe) { 
    System.err.println("Problem creating server socket:" + ioe); 
System.exit(-1); } 
    //       
    //    . 
    try*{ 
    Socket s; 
    while (null != (s = m_sqcketServer.accept()}) { new SimpleFileServer(s); s.close(}; 
    m_socketServer.close() ; } catch (lOException ioe) ( 
    System.err.println("Server socket problem: " + ioe); } 


     . 	27 


    //     SimpleFileServer. 
    //             . 
    private  SimpleFileServer(Socket  socket)   throws   lOException   { 
    //        -   . 
    DatalnputStream in = new DatalnputStream(socket.getlnputStreamf)) ; 
    DataOutputStream out = new DataOutputStream(socket.getOutputStream()) ; 
    //      . 
    int  nType  =  in.readlnt(); 
    String strFilename =  in.readUTF(); 
    //    (|),    FileOutputStream // 
'~"  .	.     .  .          ..          .          .   
,  , if (_Q  =_=  nType)    { try   { 
    FileOutputStream  file__out   = 
    new FileOutputStream(strFilename); 
    for(int  n   ;   -1    !=   (n  =   in.readO)    ;   ) 
    file_out.write(n); }   catch   (EOFException  eof)    { } 
    //      ,      FilelnputStream. }   
else  if   (1  == jiType)    { try   {    * 
    FilelnputStream file_in =new FilelnputStream(strFilename); 
    for(int   n   ;   -1   !=   (n  =   file_in.read())    ;    ) 
    out.write(n); 
    } catch (EOFException eof) { } } 
    //   , in.close (); out.close(); } } 

      -   .  ,   
  .       
       ,  ,  - 
 . , ,      , 
       -!   
  ,     ,   
   .   ^^^^  
,   	~~"~"" "" 

    28	Visual J++:   


    ,    ,    

      ,       
  ,       . 
      .        
 .   ,  -    
   ,      .  
  ,  ,    ,  ,  
   .    ,  " " 
 WWW-,         
    . 
      ,   ,   ^   
    .    
  (, ,    ) 
     Internet.    , 
 ,  ,    WWW-,  
    ,   .  ,  Java 
,  ,    . 
     ,     ,  WWW-,  
  .       
,          Internet. 
       MyStoringApplet ,   .  
WWW-.     ,   : 

    Socket s = new Socket(InetAddress.getByName(getDocumentBase()),nPort); 

        ,    ,    
 .      " 
    WWW-,  . 

      - 

      -       Internet Explorer 
.     ,   
-           4$. 
     ,       MS Word,  
 -.   Word Basic,  %1  
 Word      ,   
      .   
 Java-       -. 

     6. 	29 

             
 (digital signature).     , 
 ""    CAB   .  
      ,   
   ,  .    
 -,         
Internet   ,      WWW-,   
 . 
        Visual J++   "Java and COM/Using 
Java with COM/Using Java and COM Together/Creating a Signed CAB file"  
,         -.   
   CAB&SIGN. 
