Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[Struts and FOP] : IllegalStateException

2 views
Skip to first unread message

MC

unread,
May 31, 2005, 11:05:50 AM5/31/05
to
Hi to all,

First excuse my bad english ;-)

I've developped a struts web application with WSAD 5.1.2 and i've
written the following code in an action class in order to send PDF in
browser (i'm using FOP):


*******************************************************************************
public ActionForward printPdf(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response,
ActionErrors errors,
ActionMessages messages)
throws Exception {

Object lst = request.getSession().getAttribute("lst");

if (lst != null) {

ArrayList lstItems = (ArrayList) lst;

byte[] content =
MyAppUtils.imprimerPdf(lstItems).toByteArray();

response.setContentType("application/pdf");
response.setContentLength(content.length);
response.getOutputStream().write(content);
response.getOutputStream().flush();
response.getOutputStream().close();
}

return null;
}
*******************************************************************************

when i run my application under websphere 5, the pdf appears in the
browser but i've always the following error :


[Servlet Error]-[OutputStream already obtained]:
java.lang.IllegalStateException: OutputStream
already obtained at
com.ibm.ws.webcontainer.srt.SRTServletResponse.getWriter(SRTServletResponse.java:450)
at com.ibm.ws-
.webcontainer.servlet.HttpServletResponseProxy.getWriter(HttpServletResponseProxy.java:123)
at
org.apache.jasper.runtime.JspWriterImpl.initOut

Please help me with this error as I am totally lost. Is
there some bug?

Thanks for your answers

Marie

0 new messages