cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Christian Schlichtherle" <christ...@schlichtherle.de>
Subject RE: Write binary data (file content) to the output stream
Date Wed, 27 Jun 2007 11:26:35 GMT
Hi,
 
I wonder if you really need a pipeline for your example, a simple Servlet
may actually be the best option.
 
If your binary file would be the result of a transformation however, I would
recommend to write a Serializer component.
 
Kind regards,
Christian


  _____  

From: Ahmet.Tokalak@Bertelsmann.de [mailto:Ahmet.Tokalak@Bertelsmann.de] 
Sent: Wednesday, June 27, 2007 1:10 PM
To: users@cocoon.apache.org
Subject: Write binary data (file content) to the output stream


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