You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ofbiz.apache.org by Ruth Hoffman <rh...@aesolves.com> on 2009/06/28 17:15:20 UTC
Is it possible to do this?
Hello All:
Can I stream a PDF (from a file within the OFBiz directory) to a browser
without getting a:
java.lang.IllegalStateException: getOutputStream() has already been
called for this response
error?
What I really want to do is stream a PDF file inline with my Screen
Widget/Freemarker Template (so I can re-render the same form, without
request parameters) that the User submitted to initiate the download. I
apologize in advance if this seems like a trivial question - but I tried
several different ways of coding this and they all come up with this
error and (of course) my form still displays the previously entered
request parameters. BTW, I don't get the error if I set my request-map
type="none", but If I do that, then I can't redisplay the form (which I
guess would be obvious to those who understand how this works :-)
Regards,
Ruth
Re: Is it possible to do this?
Posted by Ruth Hoffman <rh...@aesolves.com>.
Hi David:
Thanks. That is what I'll do - the Javascript solution.
Ruth
David E Jones wrote:
>
> You do have to choose with HTTP: either return HTML or other text, or
> return a binary file. No, you can't do both in one response (it's not
> like email with attachments and such).
>
> If you take a look at all of the OOTB PDF responses you'll see they
> use the Screen Widget and such, but for a purely PDF binary response
> and not combined with HTML.
>
> If you want both you can return HTML that has JavaScript in it that
> automatically sends a request for the binary file and if you do it
> right the effect will be that the user sees the HTML page and shortly
> thereafter a download automatically begins.
>
> -David
>
>
> On Jun 28, 2009, at 9:15 AM, Ruth Hoffman wrote:
>
>> Hello All:
>> Can I stream a PDF (from a file within the OFBiz directory) to a
>> browser without getting a:
>> java.lang.IllegalStateException: getOutputStream() has already been
>> called for this response
>> error?
>>
>> What I really want to do is stream a PDF file inline with my Screen
>> Widget/Freemarker Template (so I can re-render the same form, without
>> request parameters) that the User submitted to initiate the download.
>> I apologize in advance if this seems like a trivial question - but I
>> tried several different ways of coding this and they all come up with
>> this error and (of course) my form still displays the previously
>> entered request parameters. BTW, I don't get the error if I set my
>> request-map type="none", but If I do that, then I can't redisplay the
>> form (which I guess would be obvious to those who understand how this
>> works :-)
>>
>> Regards,
>> Ruth
>
>
Re: Is it possible to do this?
Posted by David E Jones <de...@me.com>.
You do have to choose with HTTP: either return HTML or other text, or
return a binary file. No, you can't do both in one response (it's not
like email with attachments and such).
If you take a look at all of the OOTB PDF responses you'll see they
use the Screen Widget and such, but for a purely PDF binary response
and not combined with HTML.
If you want both you can return HTML that has JavaScript in it that
automatically sends a request for the binary file and if you do it
right the effect will be that the user sees the HTML page and shortly
thereafter a download automatically begins.
-David
On Jun 28, 2009, at 9:15 AM, Ruth Hoffman wrote:
> Hello All:
> Can I stream a PDF (from a file within the OFBiz directory) to a
> browser without getting a:
> java.lang.IllegalStateException: getOutputStream() has already been
> called for this response
> error?
>
> What I really want to do is stream a PDF file inline with my Screen
> Widget/Freemarker Template (so I can re-render the same form,
> without request parameters) that the User submitted to initiate the
> download. I apologize in advance if this seems like a trivial
> question - but I tried several different ways of coding this and
> they all come up with this error and (of course) my form still
> displays the previously entered request parameters. BTW, I don't get
> the error if I set my request-map type="none", but If I do that,
> then I can't redisplay the form (which I guess would be obvious to
> those who understand how this works :-)
>
> Regards,
> Ruth