You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Emi Lu <em...@encs.concordia.ca> on 2011/03/23 15:39:04 UTC
struts2 + itext5 + pdf generation
Good morning list,
A question about struts2 + PDF. Struts2 + itext5.x.
In action class:
==========================================
HttpServletResponse res = ServletActionContext.getResponse();
res.setContentType("application/pdf");
Document document = new Document();
PdfWriter.getInstance(document,
res.getOutputStream());
document.open();
...
document.close();
Always got the following errors:
====================================
ERROR tags.BaseSimpleTag.doEndTag:? - ERROR: getOutputStream() has
already been called for this response
org.apache.catalina.core.ApplicationDispatcher invoke
SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.IllegalStateException: getOutputStream() has already been
called for this response
Is there a way to fix it and is there any good online doc about how
struts2 + itext pdf file generation?
Also, how do you setup the default PDF file name?
Thanks a lot!
Emi
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: struts2 + itext5 + pdf generation
Posted by Paweł Wielgus <po...@gmail.com>.
Hi Emi,
maybe this will help a little:
http://struts.apache.org/2.2.1/docs/stream-result.html
Best greetings,
Paweł Wielgus.
2011/3/23 Emi Lu <em...@encs.concordia.ca>:
>>
>> A question about struts2 + PDF. Struts2 + itext5.x.
>>
>> In action class:
>> ==========================================
>> HttpServletResponse res = ServletActionContext.getResponse();
>> res.setContentType("application/pdf");
>> Document document = new Document();
>> PdfWriter.getInstance(document,
>> res.getOutputStream());
>> document.open();
>> ...
>> document.close();
>>
>> Always got the following errors:
>> ====================================
>> ERROR tags.BaseSimpleTag.doEndTag:? - ERROR: getOutputStream() has
>> already been called for this response
>> org.apache.catalina.core.ApplicationDispatcher invoke
>> SEVERE: Servlet.service() for servlet jsp threw exception
>> java.lang.IllegalStateException: getOutputStream() has already been
>> called for this response
>
>
>> Also, how do you setup the default PDF file name?
>
>
> I fixed the above by trying the following:
> (1) Change action class to void
>
> (2) Added response.setHeader("Content-disposition","attachment; filename=\""
> + reportName + ".pdf\"" );
>
>> Is there a way to fix it and is there any good online doc about how
>> struts2 + itext pdf file generation?
>
> I'd like to get some good online docs about struts2 + jsperreport, or
> struts2 + itext pdf generation.
>
> Thanks alot!
> Emi
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: struts2 + itext5 + pdf generation
Posted by Emi Lu <em...@encs.concordia.ca>.
>
> A question about struts2 + PDF. Struts2 + itext5.x.
>
> In action class:
> ==========================================
> HttpServletResponse res = ServletActionContext.getResponse();
> res.setContentType("application/pdf");
> Document document = new Document();
> PdfWriter.getInstance(document,
> res.getOutputStream());
> document.open();
> ...
> document.close();
>
> Always got the following errors:
> ====================================
> ERROR tags.BaseSimpleTag.doEndTag:? - ERROR: getOutputStream() has
> already been called for this response
> org.apache.catalina.core.ApplicationDispatcher invoke
> SEVERE: Servlet.service() for servlet jsp threw exception
> java.lang.IllegalStateException: getOutputStream() has already been
> called for this response
> Also, how do you setup the default PDF file name?
I fixed the above by trying the following:
(1) Change action class to void
(2) Added response.setHeader("Content-disposition","attachment;
filename=\"" + reportName + ".pdf\"" );
> Is there a way to fix it and is there any good online doc about how
> struts2 + itext pdf file generation?
I'd like to get some good online docs about struts2 + jsperreport, or
struts2 + itext pdf generation.
Thanks alot!
Emi
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org