Multipart/mixed content: html, pdf
843840Jun 27 2002 — edited Jun 26 2003Hi.
I have a problem sending multipart content back to a browser through the response object.
What I want is to send a "Please be patient" html page while a pdf is created and send it as a second part as soon as it is created and can't get it to work.
The problem is, the pdf just does not show up. The html sent first is removed from display, the plugin starts but then nothing happens and I end up with a blank browser window.
Code snippet:
---------------------------
response.setContentType( "multipart/mixed;boundary=" + boundary );
ServletOutputStream outStream = response.getOutputStream();
response.addHeader( "MIME-Version", "1.0" );
outStream.println( "" );
outStream.println( "--" + boundary );
response.addHeader( "Content-Type", "text/html" );
response.addHeader( "Content-Transfer-Encoding", "chunked" );
outStream.println( "" );
outStream.println( "<html>" );
outStream.println( "<head><title>Supplier Info</title></head>" );
outStream.println( "<body>" );
outStream.println( "<p>Please be patient...</p>" );
outStream.println( "</body></html>" );
outStream.println( "" );
outStream.println( "--" + boundary );
outStream.flush();
// create pdf and write it into a byte array called 'result'
response.addHeader( "Content-Type", "application/pdf" );
response.addHeader( "Content-Transfer-Encoding", "chunked" );
response.addHeader( "Content-Disposition", "inline" );
outStream.println( "" );
System.out.println( "result.length: " + result.length ); //result contains data!
outStream.write( result );
outStream.println( "" );
outStream.println( "--" + boundary + "--" );
outStream.println( "" );
outStream.flush();
------------------------------------
Please could somebody tell me what's wrong with my code? Am I missing something?
My environment is Win2k, Borland JDev 3.2.3, Mozilla 1.0.
TIA
Ralf Steppacher