You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Benjamin Ernst <be...@gmail.com> on 2007/10/26 12:31:37 UTC
IllegalStateException when delivering a PDF
Hi guys,
I am delivering a PDF-Document with wicket like this:
Document document = new Document();
String filename = "bestandsfax.pdf";
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PdfWriter.getInstance(document, baos);
document.open();
BestandsfaxCreator bfc = new BestandsfaxCreator(filiale, grp);
bfc.createBestandsfax(document);
document.close();
WebResponse response = (WebResponse) getResponse();
response.setHeader("Expires", "0");
response.setHeader("Cache-Control", "must-revalidate,
post-check=0, pre-check=0");
response.setHeader("Pragma", "public");
response.setHeader("Content-Disposition", "attachment;filename="
+ filename);
response.setContentType("application/pdf");
// the contentlength is needed for MSIE!!!
response.setContentLength(baos.size());
OutputStream outputStream = response.getOutputStream();
outputStream.write(baos.toByteArray());
outputStream.flush();
This works fine, except taht there is an IllegalStateException thrown after
the delivery.
2007-10-26 12:19:59,062 ERROR [http-8080-Processor25]
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/frontend].[default]:
Servlet.service() for servlet default threw exception
java.lang.IllegalStateException
at org.apache.catalina.connector.ResponseFacade.sendRedirect(
ResponseFacade.java:433)
at org.apache.wicket.protocol.http.WebResponse.redirect(WebResponse.java
:214)
at org.apache.wicket.protocol.http.BufferedWebResponse.close(
BufferedWebResponse.java:67)
at org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java
:271)
at org.apache.wicket.protocol.http.WicketFilter.doFilter(
WicketFilter.java:127)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(
ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(
StandardWrapperValve.java:210)
at org.apache.catalina.core.StandardContextValve.invoke(
StandardContextValve.java:174)
at org.apache.catalina.core.StandardHostValve.invoke(
StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(
ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(
StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(
CoyoteAdapter.java:151)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:870)
at
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection
(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(
PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(
LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(
ThreadPool.java:685)
at java.lang.Thread.run(Thread.java:619)
This has no effect on the PDF, or the Wicket-Application that I could
discover. Anyhow it would be nicer, if there was no Exception.
Has anyone an idea how to get rid of it?
Regards,
Benjamin
Re: IllegalStateException when delivering a PDF
Posted by Benjamin Ernst <be...@gmail.com>.
Thanks for your help. It works great!
- Benjamin
2007/10/26, martinf <fu...@arcor.de>:
>
>
> Hi,
>
> it's the flush() that's bad.
>
> Best answer to your question of streaming PDF's to the client is:
>
> http://www.nabble.com/Stream-Excel-to-the-client-tf1955606.html#a5364044
>
> mf
>
>
> Benjamin Ernst wrote:
> >
> > Hi guys,
> >
> > I am delivering a PDF-Document with wicket like this:
> >
> >
> > Document document = new Document();
> > String filename = "bestandsfax.pdf";
> > ByteArrayOutputStream baos = new ByteArrayOutputStream();
> > PdfWriter.getInstance(document, baos);
> > document.open();
> >
> > BestandsfaxCreator bfc = new BestandsfaxCreator(filiale,
> grp);
> > bfc.createBestandsfax(document);
> >
> > document.close();
> >
> > WebResponse response = (WebResponse) getResponse();
> > response.setHeader("Expires", "0");
> > response.setHeader("Cache-Control", "must-revalidate,
> > post-check=0, pre-check=0");
> > response.setHeader("Pragma", "public");
> >
> > response.setHeader("Content-Disposition",
> > "attachment;filename="
> > + filename);
> >
> > response.setContentType("application/pdf");
> >
> > // the contentlength is needed for MSIE!!!
> > response.setContentLength(baos.size());
> >
> > OutputStream outputStream = response.getOutputStream();
> > outputStream.write(baos.toByteArray());
> > outputStream.flush();
> >
> > This works fine, except taht there is an IllegalStateException thrown
> > after
> > the delivery.
> >
> > 2007-10-26 12:19:59,062 ERROR [http-8080-Processor25]
> > org.apache.catalina.core.ContainerBase
> .[Catalina].[localhost].[/frontend].[default]:
> > Servlet.service() for servlet default threw exception
> > java.lang.IllegalStateException
> > at org.apache.catalina.connector.ResponseFacade.sendRedirect(
> > ResponseFacade.java:433)
> > at
> > org.apache.wicket.protocol.http.WebResponse.redirect(WebResponse.java
> > :214)
> > at org.apache.wicket.protocol.http.BufferedWebResponse.close(
> > BufferedWebResponse.java:67)
> > at
> > org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java
> > :271)
> > at org.apache.wicket.protocol.http.WicketFilter.doFilter(
> > WicketFilter.java:127)
> > at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
> > ApplicationFilterChain.java:215)
> > at org.apache.catalina.core.ApplicationFilterChain.doFilter(
> > ApplicationFilterChain.java:188)
> > at org.apache.catalina.core.StandardWrapperValve.invoke(
> > StandardWrapperValve.java:210)
> > at org.apache.catalina.core.StandardContextValve.invoke(
> > StandardContextValve.java:174)
> > at org.apache.catalina.core.StandardHostValve.invoke(
> > StandardHostValve.java:127)
> > at org.apache.catalina.valves.ErrorReportValve.invoke(
> > ErrorReportValve.java:117)
> > at org.apache.catalina.core.StandardEngineValve.invoke(
> > StandardEngineValve.java:108)
> > at org.apache.catalina.connector.CoyoteAdapter.service(
> > CoyoteAdapter.java:151)
> > at
> > org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
> > :870)
> > at
> >
> org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection
> > (Http11BaseProtocol.java:665)
> > at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(
> > PoolTcpEndpoint.java:528)
> > at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(
> > LeaderFollowerWorkerThread.java:81)
> > at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(
> > ThreadPool.java:685)
> > at java.lang.Thread.run(Thread.java:619)
> >
> >
> > This has no effect on the PDF, or the Wicket-Application that I could
> > discover. Anyhow it would be nicer, if there was no Exception.
> >
> > Has anyone an idea how to get rid of it?
> >
> > Regards,
> > Benjamin
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/IllegalStateException-when-delivering-a-PDF-tf4696461.html#a13426118
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
Re: IllegalStateException when delivering a PDF
Posted by martinf <fu...@arcor.de>.
Hi,
it's the flush() that's bad.
Best answer to your question of streaming PDF's to the client is:
http://www.nabble.com/Stream-Excel-to-the-client-tf1955606.html#a5364044
mf
Benjamin Ernst wrote:
>
> Hi guys,
>
> I am delivering a PDF-Document with wicket like this:
>
>
> Document document = new Document();
> String filename = "bestandsfax.pdf";
> ByteArrayOutputStream baos = new ByteArrayOutputStream();
> PdfWriter.getInstance(document, baos);
> document.open();
>
> BestandsfaxCreator bfc = new BestandsfaxCreator(filiale, grp);
> bfc.createBestandsfax(document);
>
> document.close();
>
> WebResponse response = (WebResponse) getResponse();
> response.setHeader("Expires", "0");
> response.setHeader("Cache-Control", "must-revalidate,
> post-check=0, pre-check=0");
> response.setHeader("Pragma", "public");
>
> response.setHeader("Content-Disposition",
> "attachment;filename="
> + filename);
>
> response.setContentType("application/pdf");
>
> // the contentlength is needed for MSIE!!!
> response.setContentLength(baos.size());
>
> OutputStream outputStream = response.getOutputStream();
> outputStream.write(baos.toByteArray());
> outputStream.flush();
>
> This works fine, except taht there is an IllegalStateException thrown
> after
> the delivery.
>
> 2007-10-26 12:19:59,062 ERROR [http-8080-Processor25]
> org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/frontend].[default]:
> Servlet.service() for servlet default threw exception
> java.lang.IllegalStateException
> at org.apache.catalina.connector.ResponseFacade.sendRedirect(
> ResponseFacade.java:433)
> at
> org.apache.wicket.protocol.http.WebResponse.redirect(WebResponse.java
> :214)
> at org.apache.wicket.protocol.http.BufferedWebResponse.close(
> BufferedWebResponse.java:67)
> at
> org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java
> :271)
> at org.apache.wicket.protocol.http.WicketFilter.doFilter(
> WicketFilter.java:127)
> at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
> ApplicationFilterChain.java:215)
> at org.apache.catalina.core.ApplicationFilterChain.doFilter(
> ApplicationFilterChain.java:188)
> at org.apache.catalina.core.StandardWrapperValve.invoke(
> StandardWrapperValve.java:210)
> at org.apache.catalina.core.StandardContextValve.invoke(
> StandardContextValve.java:174)
> at org.apache.catalina.core.StandardHostValve.invoke(
> StandardHostValve.java:127)
> at org.apache.catalina.valves.ErrorReportValve.invoke(
> ErrorReportValve.java:117)
> at org.apache.catalina.core.StandardEngineValve.invoke(
> StandardEngineValve.java:108)
> at org.apache.catalina.connector.CoyoteAdapter.service(
> CoyoteAdapter.java:151)
> at
> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
> :870)
> at
> org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection
> (Http11BaseProtocol.java:665)
> at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(
> PoolTcpEndpoint.java:528)
> at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(
> LeaderFollowerWorkerThread.java:81)
> at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(
> ThreadPool.java:685)
> at java.lang.Thread.run(Thread.java:619)
>
>
> This has no effect on the PDF, or the Wicket-Application that I could
> discover. Anyhow it would be nicer, if there was no Exception.
>
> Has anyone an idea how to get rid of it?
>
> Regards,
> Benjamin
>
>
--
View this message in context: http://www.nabble.com/IllegalStateException-when-delivering-a-PDF-tf4696461.html#a13426118
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org