Sharad,

I am attaching something which was my reply to a very similar question.

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>

Nathan,

Here is something for you from ND docs.

Once you get a CSpStringOutputStream containing the generated Html text,
writing it out into a file on the Server should not be difficult.

Regards,

Aby

=======================================================================

 public abstract int onBeforeHtmlOutputEvent(CSpHtmlOutputEvent event)
throws CSpSkipException
, CSpStopException 
 

Ideas for tasks you can accomplish by overriding this event: 

� Make changes to the generated HTML after the fact. This requires
redirection of the output stream to an internal buffer before the
display() begins. Then, once this event is triggered, you can obtain the
generated HTML, make modifications to it (e.g. by replacing some place
holder token with the "latest news" String) and write out the final
results. Here is the framework for this technique: 

  protected int 
      onBeforeDisplayEvent ( 
         ) 
   { 
      // Save the original output stream 
      _origStream = CSpider.getOutputStream (); 

      // Construct a byte array output stream and create a 
      // CSpStringOutputStream out of it 
      _myArrayStream = new ByteArrayOutputStream (10000); 
      _myStream = new CSpStringOutputStream (_myArrayStream); 

      // Set our temporary string output stream to be used 
      // when constructing the HTML ("stealing" the HTML page) 
      CSpider.setOutputStream (_myStream); 

      return (PROCEED_WITH_BUILTIN_HANDLING); 
   } 

   protected int 
      onBeforeHtmlOutputEvent ( 
         ) 
   { 
      try 
      { 
         // Flush everything so that our byte array will get loaded 
         // with the HTML 
         CSpHtml.flush (_myStream); 

         // Convert the byteArray into a String 
         String   htmlPage = _myArrayStream.toString (); 

         // Restore the original output stream 
         CSpider.setOutputStream (_origStream); 

         // Make some late changes to the HTML 
         String modifiedHtmlPage = 
                 CSpUtil.replaceSubstring (htmlPage, 
                                           ............); 
         // Write the modified HTML out 
         CSpHtml.sendRawDataItem (_origStream, modifiedHtmlPage); 
      } 
      catch (Exception  ex) 
      { 
         // Shouldn't occur 
      } 

      return (PROCEED_WITH_BUILTIN_HANDLING); 
   } 

   protected CSpStringOutputStream _origStream    = null; 
   protected ByteArrayOutputStream _myArrayStream = null; 
   protected CSpStringOutputStream _myStream      = null; 

=======================================================================


-----Original Message-----
From: Sharad Singh [mailto:[EMAIL PROTECTED]]
Sent: Friday, August 13, 1999 12:58 PM
To: [EMAIL PROTECTED]
Subject: [ND] How to create File with HTML output from App Server



Is anyone aware of a procedure for creating a file with the exact same
HTML text that
is created as a result of an event generating an HTML page. In other
words, besides
displaying the HTML content in a browser window, I also I need to create
an HTML file
with the same text, which can be viewed in any browser.

There should probably be a way to read the cached data corresponding to
the displayed
HTML text and storing it ina file.

Any help will be greatly appreciated.
_________________________________________________________________________

For help in using, subscribing, and unsubscribing to the discussion
forums, please go to: http://www.netdynamics.com/support/visitdevfor.html

For dire need help, email: [EMAIL PROTECTED]

Reply via email to