I met the same problem some time ago...
I had the solution but it works too bad for big files.
So then i changed it (with customer confirmation) to just urls.

You must have an empty nd-page with special string to replace content (e.g:VeryBegin).

In onBeforeDisplay for page use CSpider.getOutputStream () to save original stream
and CSpider.setOutputStream (_myStream) for redirect nd-formatting.

In onBeforeHtmlOutput you have to get html-source of page, get substring before 
"VeryBegin".
It will be http-header.
Replace "text/html" with your file's mime.
Send header using CSpHtml.sendRawDataItem(_origStream)
Then open your file and send it block by block  using CSpHtml.sendRawDataItem
At the end call CSpHtml.flush(_origStream);

Warning! It works slowly! And tested only in Nd v.3.1.3.

---------------------- EXAMPLE source------------------
import spider.*;                         
import spider.access.*;         
import spider.util.*;           
import spider.session.*;        
import spider.database.*;
import spider.visual.*;
import spider.html.*;

import java.net.*;
import java.io.*;

import spider.event.*;

import spider.event.*;

//[[SPIDER_CLASS BEGIN
final public class pgaShowBody extends CSpPage
//]]SPIDER_CLASS END
{
  protected CSpStringOutputStream _origStream    = null; 
  protected ByteArrayOutputStream _myArrayStream = null; 
  protected CSpStringOutputStream _myStream      = null;
  protected static String file_ext[]={
          "txt", "c", "cp", "cpp", "p", "pas", "jav",
          "java","prg", "bat", "h", "hpp", "ini", "sql",
          "htm", "html", "asp", "shtml",
          "gif", "jpg", "jpeg", "bmp", "pcx", "tif", "tiff",
          "rtf", "doc",
          "xls", "xlc", "xlt", "xlw", "xlm", "xld", "xla", "xll",
          "dbf", "pdf",
          "gz", "hqx", "sit", "cpt",
          "zip", "rar", "tar", "z",
          "exe", "sea",
          "ins","isp", "eml","nws", "url",
        "bin", "class",
        "aif", "aiff", "wav", "midi", "mid", "mov", "qt",
        "mpg", "mpeg", "dat", "avi", "dd"
  };
  protected static String mime_type[]={
        "text/plain", "text/plain", "text/plain", "text/plain", "text/plain", 
"text/plain", "text/plain",
        "text/plain", "text/plain", "text/plain", "text/plain", "text/plain", 
"text/plain", "text/plain",
        "text/html", "text/html", "text/html", "text/html",
        "image/gif", "image/jpeg", "image/jpeg", "image/x-MS-bmp", "image/pcx", 
"image/tiff", "image/tiff",
        "application/rtf", "application/msword",
        
"application/vnd.ms-excel","application/vnd.ms-excel","application/vnd.ms-excel",
        
"application/vnd.ms-excel","application/vnd.ms-excel","application/vnd.ms-excel",
        "application/vnd.ms-excel","application/vnd.ms-excel",
        "application/dbf", "application/pdf",
        "application/x-gzip", "application/mac-binhex40", "application/x-stuffit",  
"application/x-stuffit",
        "application/x-zip-compressed", "application/rar", "application/x-tar", 
"application/x-compress",
        "application/x-msdownload", "application/self-extracting",
        "application/x-internet-signup", "application/x-internet-signup", 
"message/rfc822", "message/rfc822", "text/url",
        "application/x-macbinary", "application/x-class",
        "audio/x-aiff", "audio/x-aiff", "audio/x-wav", "audio/x-midi", "audio/x-midi", 
"video/quicktime", "video/quicktime",
        "video/mpeg", "video/mpeg", "video/mpeg", "video/x-msvideo", 
"application/mac-diskdoubler"
  };
  

        public static String GetMIMEByFileName (String file_name) {
                String name=AzUt.GetFileExt(file_name, "");
                String res="application/octet-stream";
                int i=0;
                if (name.length()==0) return res;
                for (i= -1; ++i < file_ext.length; ) {
                        if (name.equals(file_ext[i])) {
                                res=mime_type[i];
                                break;
                        }
                }
                return res;
        }
        
        synchronized protected String GetHtml() {
                String   htmlPage="";
                // Flush everything so that our byte array will get loaded 
                // with the HTML
                try {
                        CSpHtml.flush (_myStream);
        
                        // Convert the byteArray into a String
                        htmlPage=_myArrayStream.toString ();
                
                        // Restore the original output stream
                        CSpider.setOutputStream (_origStream);
                        _myStream.close();
                        _myArrayStream.reset();
                        _myStream=null;
                        _myArrayStream=null;
                }
                catch (Exception  ex) {
                        // send any exceptions to the Log
                        htmlPage=null;
                        AzUt.send ("pgaShowBody.onBeforeHtmlOutputEvent: " + ex );
                }
                return htmlPage;

        }
        
        //[[SPIDER_EVENTS BEGIN
        
        //[[SPIDER_EVENT<onBeforeDisplayEvent ()>
        synchronized protected int onBeforeDisplayEvent ()
        {
                CSpValue body_doc=CSpider.getUserSessionObject("soa_BODY_DOC");
                if (AzUt.isNull(body_doc)) {
                        AzUt.Message("Empty file name", "AzaDobro.pgaMoveEdit");
                        return STOP;
                }
                //�������� ������� �����
                File f=new File(body_doc.toString());
                if (! f.canRead()) {
                        AzUt.Message("File "+body_doc.toString()+" is not found.", 
"AzaDobro.pgaMoveEdit");
                        return STOP;
                }
                                
                
                // Save the original output stream
                if (_myArrayStream == null && _myStream==null) {
                        if (_origStream==null) {
                                _origStream = CSpider.getOutputStream ();
                        }
                // Construct a byte array output stream and create a 
                // CSpStringOutputStream out of it
                        _myArrayStream = new ByteArrayOutputStream (600);
                        _myStream = new CSpStringOutputStream (_myArrayStream); 
                }
                else {
                        AzUt.Message("Server is busy", "AzaDobro.pgaShowBody");
                        return STOP;
                }
                // Set our temporary string output stream to be used 
                // when constructing the HTML ("stealing" the HTML page) 
                CSpider.setOutputStream (_myStream);
                
                return PROCEED;
        }
        //]]SPIDER_EVENT<onBeforeDisplayEvent ()>

        //[[SPIDER_EVENT<onBeforeHtmlOutputEvent ()>
        protected int onBeforeHtmlOutputEvent ()
        {
                int command = SKIP;
                CSpValue body_doc=CSpider.getUserSessionObject("soa_BODY_DOC");
                if (AzUt.isNull(body_doc)) {
                        CSpHtml.reset (); 
                        CSpHtml.setAutoMode (true); 
                        CSpHttp.reset (); 
                        CSpHttp.setAutoMode (true); 
                        AzUt.Message("File name is empty", "AzaDobro.pgaMoveEdit");
                        return STOP;
                }
                try {
        
                        // Convert the byteArray into a String
                        String   htmlPage=GetHtml();
                                                                
                        String file_name=body_doc.toString();

                        File f=new File(file_name);

                        int i=htmlPage.indexOf("AzaBodyDoc");
//if name is good
                        if (i>=0 && f.exists()) {

        //leave header
                                htmlPage=htmlPage.substring(0,i);
                                
                                htmlPage=CSpUtil.replaceSubstring(
                                        htmlPage,"text/html", 
GetMIMEByFileName(f.getName()) );
                                        
                                // Write the modified HTML out
                                CSpHtml.sendRawDataItem (_origStream, htmlPage);

                                CSpHtml.setFooterHasBeenSent(true);
                                CSpHtml.setHeaderHasBeenSent(true);
                                
                                BufferedInputStream buf_in=new BufferedInputStream(new 
FileInputStream(f), 512);
                                if (buf_in != null) {
                                        String s;
                                        int res;
                                        char c[]=new char[512];
                                        i=0;
                                        while (true) {
                                                res=buf_in.read();
                                                if (res== -1) break;
                                                c[i]=(char)res;
                                                if (++i >= 512) {
                                                        
CSpHtml.sendRawDataItem(_origStream, new String(c, 0, i) );
                                                        i=0;
                                                }
                                        }
                                        
                                        if (i>0) {
                                                CSpHtml.sendRawDataItem(_origStream, 
new String(c, 0, i) );
                                                i=0;
                                        }
                                        //CSpHtml.sendRawDataItem(_origStream, 
"\n---File name="+f.getName()+"\n---MIME="+GetMIMEByFileName(f.getName())+"\n");
                                        CSpHtml.flush(_origStream);
                                        buf_in.close();
                                }
                                CSpHtml.setFooterHasBeenSent(true);
                                CSpHtml.setHeaderHasBeenSent(true);
                                
                        }//if substring found
                        else {
                                CSpHtml.reset (); 
                                CSpHtml.setAutoMode (true); 
                                CSpHttp.reset (); 
                                CSpHttp.setAutoMode (true); 
                                AzUt.Message("������ ��� �������� ��� �����. �� ���� 
������� ������� �����", "AzaDobro.pgaMoveEdit");
                                command=STOP;
                        }

                        //AzUt.send("Output 
stream="+_myArrayStream.toString()+"$$$$$$$");

                }//try
                catch (Exception  ex) {
                        // send any exceptions to the Log
                        CSpHtml.reset (); 
                        CSpHtml.setAutoMode (true); 
                        CSpHttp.reset (); 
                        CSpHttp.setAutoMode (true); 
                        command = STOP;
                        AzUt.Message("pgaShowBody.onBeforeHtmlOutputEvent: " + ex, 
"AzaDobro.pgaMoveEdit");
                }

                _myStream=null;
                _myArrayStream=null;
                _origStream=null;
                return command;
        }
        //]]SPIDER_EVENT<onBeforeHtmlOutputEvent ()>

        //]]SPIDER_EVENTS END
}


------------------------------------------------------------------
"Senthil" <[EMAIL PROTECTED]> wrote:
>
>Hello,
>        String url = "http://localhost:81/cgi-bin/ndCGI.exe/ProjectName/PageName" +
>                 "?userId=xyz"  +
>                              "&passwd=pswd";
>                 CSpHttp.reset();
>                 CSpHttp.setAutoMode(false);   
>                 CSpHttp.setHttpStatus(302);               
>                 CSpHttp.write("Location:" + url );
>                 CSpHttp.write("\n\n"); 
>
>The above code redirects the browser to the url specified above. The URL parameters 
>are visible, which I donot want to be visible. How to simulate the same thing as
>POST operation rather than GET ? or is there a way to send those information as 
>HTTP Headers?
>
>Thanks,
>S.Senthil Kumar


_________________________________________________________________________
To unsubscribe from this mailing list please send an email to:
[EMAIL PROTECTED]
Please remember to use the same email address you subscribed with.

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