cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <Ahmet.Toka...@Bertelsmann.de>
Subject Write binary data (file content) to the output stream
Date Wed, 27 Jun 2007 11:09:50 GMT
Hi all, 
 
i wanna open a generate a binary file on the fly and write send it directly to the user.
 
I didn't found an easy way in cocoon to achieve this.
 
Therefore i have tried using an action, which gets the output stream and writes the byte array
into the stream.
...
response.setContentType("application/x-octet-stream");

response.setHeader("Content-Disposition", "attachment; filename=" + filename);

OutputStream out = response.getOutputStream();

out.write(data);

out.flush();

...

 
 
 
the sitemap.xmap looks like this:
 
<map:match pattern="**download.do">

<map:act type="binary-download"/>

</map:match> 

 
 
It does function, but when i open in an editor, then i see the file content followed by an
cocoon error message saying that a ResourceNotFoundException has been occured.
 
1. Any idea why i get the message?
2. Is there a better way sending binary data without writing it to the filesystem?
 
Thanks in advance.
 

Mime
View raw message