You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by "Yeeswara Nadapana (HCL Financial Services)" <Ye...@hcl.in> on 2008/09/15 15:07:54 UTC
Error using OutputStream with Tapestry5
Hi,
I am using Tapestry 5.0.12 for my application. When I try to use the
OutputStream to export some data to excel, I get the error saying
"getOutputStream() has already been called for this response". However,
I can export the file and save it with NO problem. But, couldn't avoid
the error on the console.
Here's the code snippet I am using.
@Inject
private Response response;
response.setHeader("Content-Disposition",
"inline; attachment; filename=" + filename);
response.setHeader("Cache-Control", "max-age=0");
response.setHeader("Pragma", "public");
outputStream = response.getOutputStream("text/csv");
Can anyone help on this? Thank you.
Regards,
Yeeswar
DISCLAIMER:
-----------------------------------------------------------------------------------------------------------------------
The contents of this e-mail and any attachment(s) are confidential and intended for the named recipient(s) only.
It shall not attach any liability on the originator or HCL or its affiliates. Any views or opinions presented in
this email are solely those of the author and may not necessarily reflect the opinions of HCL or its affiliates.
Any form of reproduction, dissemination, copying, disclosure, modification, distribution and / or publication of
this message without the prior written consent of the author of this e-mail is strictly prohibited. If you have
received this email in error please delete it and notify the sender immediately. Before opening any mail and
attachments please check them for viruses and defect.
-----------------------------------------------------------------------------------------------------------------------
Re: Error using OutputStream with Tapestry5
Posted by Inge Solvoll <in...@gmail.com>.
Hi
If you want to stream text containing csv to the client, just return a
TextStreamResponse from your page method, like this:
return new TextStreamResponse("text/csv", csvText);
You can also create your own StreamResponse implementation and set your
headers in the prepareResponse() method. I did this for several pages and I
love the approach.
On Mon, Sep 15, 2008 at 3:07 PM, Yeeswara Nadapana (HCL Financial Services)
<Ye...@hcl.in> wrote:
>
> Hi,
>
>
>
> I am using Tapestry 5.0.12 for my application. When I try to use the
> OutputStream to export some data to excel, I get the error saying
> "getOutputStream() has already been called for this response". However,
> I can export the file and save it with NO problem. But, couldn't avoid
> the error on the console.
>
>
>
>
>
> Here's the code snippet I am using.
>
>
>
> @Inject
>
> private Response response;
>
>
>
> response.setHeader("Content-Disposition",
>
> "inline; attachment; filename=" + filename);
>
> response.setHeader("Cache-Control", "max-age=0");
>
> response.setHeader("Pragma", "public");
>
>
>
> outputStream = response.getOutputStream("text/csv");
>
>
>
>
>
> Can anyone help on this? Thank you.
>
>
>
>
>
> Regards,
>
> Yeeswar
>
>
>
>
>
> DISCLAIMER:
>
> -----------------------------------------------------------------------------------------------------------------------
>
> The contents of this e-mail and any attachment(s) are confidential and
> intended for the named recipient(s) only.
> It shall not attach any liability on the originator or HCL or its
> affiliates. Any views or opinions presented in
> this email are solely those of the author and may not necessarily reflect
> the opinions of HCL or its affiliates.
> Any form of reproduction, dissemination, copying, disclosure, modification,
> distribution and / or publication of
> this message without the prior written consent of the author of this e-mail
> is strictly prohibited. If you have
> received this email in error please delete it and notify the sender
> immediately. Before opening any mail and
> attachments please check them for viruses and defect.
>
>
> -----------------------------------------------------------------------------------------------------------------------