Hi !

I have the following scenario:

Servet A :    performs a synchronous call to another servlet B, located at
some other server.
                      Servlet B produces binary output, that may be further
processed or directly
                      routed back to the browser (as shown in the code
example).

     URL url = new URL("<url to servlet B with arguments>");

     URLConnection connection = url.openConnection();
     BufferedReader in = new BufferedReader(new
InputStreamReader(connection.getInputStream()));
     OutputStream f = response.getOutputStream();
     int a=0;
     while ( (a=in.read()) != -1 )
      {
         f.write(a);
      }
      in.close();
      f.close();


Servlet B:   performs some businesslogic, using server B's local
ressources.
           In this exaple an MS-Excel Document is generated and returned as
binary data.

        response.setContentType("application/x-msexcel");

          ... some action that produces File excel;
          File excel= new File(....)

          OutputStream f = response.getOutputStream();

           BufferedInputStream bis = new BufferedInputStream (new
FileInputStream(excel));
           int a=0;
           while ( (a=bis.read()) != -1 )
           {
              f.write(a);
           }
           bis.close();
           f.close();

problem/question:

If I use the URL of B directly, the generated excel-doc is displayed
correcty
If I modify Servlet B to return standard HTML/Text Output and call Servlet
A, everything works fine all well.

But: if i use the combination as shown in the code, after calling servlet
A, excel pop's up but immediately
crashes. So i suppose there is something going wrong with the binary output
of servlet B ?

Any help appreceated,

Regards,
Dirk


--
To unsubscribe:   <mailto:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>

Reply via email to