cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robin Green" <gree...@hotmail.com>
Subject Re: Formatting plain text
Date Tue, 20 Feb 2001 18:19:39 GMT
Jonathan Fuerth <fuerth@sqlpower.ca> wrote:
>I am trying to use an xsp with esql to extract data from a database
>and format it as an ascii comma-separated values (csv) file.
>
>I want the http Content-type of the output to be
>application/octet-stream in order to induce web browsers to save the
>file to disk, rather than displaying it on the screen.
>
>No matter what I try, I always get text/html.

You're not supposed to use HttpServletResponse to set the content-type - 
Cocoon does that, and on Servlet 2.2-compliant servlet engines you will get 
an exception thrown if you try to set it again.

Add these lines to cocoon.properties

formatter.type.application/octet-stream   = 
org.apache.cocoon.formatter.TextFormatter

formatter.application/octet-stream.MIME-type = application/octet-stream

Then add this line to your xml file

<?cocoon-format type="application/octet-stream"?>
after all the other processing instructions. If this doesn't work read the 
FAQ on "why do my processing instructions disappear?"

This should be okay for simple CSV but I'm going to do a LiteralFormatter to 
copy the results literally for the next version of Cocoon.




_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.


Mime
View raw message