tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ben Souther <>
Subject Re: How to Display a byte array (contents of a MS DOC fie, Excel, ..) in web browser
Date Fri, 29 Oct 2004 01:41:44 GMT
Set the content type.
Set the content disposition.
Get a servletOutputStream from the response object.
Write the bytes to the outputStream.
Flush the stream.

Sort of like this...
You'll need to add exception handling and probably buffering if you're 
streaming the byte array in and out at the same time.
There are lots of examples on the web for doing that.
This should get you started.


    "Content-Disposition", "attachment; filename=myFile.doc");

ServletOutputStream out = response.getOutputStream();

for(int i = 0; i < byteArray.length; i++){

On Thu, 2004-10-28 at 21:11, Daxin Zuo wrote:
> I receive a byte array from a remote server, and the servlet will display it
> on the browser. The byte array contains a MS DOC file. If I simply convert
> it to a String, the contents will be meaningless.
> Please forward instruction.
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message