if you generate the response yourself, you should return null in your ReportAction.

sven

Srinivas Sampige wrote:
Hi
Thanks for your reply.The code you have supplied is on the lines of what I am doing. Here is what happens. First time the action is run the PDF comes out fine to the nrowser but with this message on the server side -

2002-12-27 15:39:46 - Ctx( /etrac ): IllegalStateException in: R( /etrac + /reportAction.do + null) Cannot forward as OutputStream or Writer has already been obtained

Then I cannot generate the PDF again until I execute another action by say ... doing back to the main menu of my web app(through another action) OR say by logging out. I get the same "IllegalStateException" error in another simple test Action that I put together. Can somebody help me? The same thing works fine in as servlet. So, I am not able to understand what is special about a Struts Action! Should I be doing something else?. Here are snippets of my code-

public abstract class EtracAction extends EtacAction
{
public ActionForward perform(ActionMapping mapping,ActionForm form ,HttpServletRequest request, HttpServletResponse response) throws IOException,
ServletException
{
....
....
return performAction(mapping, form, request, response,userSessionInfo);
}

public abstract ActionForward performAction(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response, UserSessionInfo userSessionInfo) throws IOException, ServletException;

}//end of EtracAction



-----------------------------------------------
ReportAction extends EtracAction {
public org.apache.struts.action.ActionForward performAction (org.apache.struts.action.ActionMapping mapping, org.apache.struts.action.ActionForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, UserSessionInfo userSessionInfo)
throws javax.servlet.ServletException, java.io.IOException
{

byte[] reportBuffer = reportManager.generateReport(userSessionInfo);
String fileName = "";
//write the pdf to the response
if (reportBuffer != null)
{
response.setContentType("application/pdf");
response.setHeader("Window-target","report_window");
fileName = "etracPdfReport.pdf";
ServletOutputStream sout = response.getOutputStream(); //THIS IS THE CODE THAT FAILS THE SECOND TIME AROUND,HAVE TO EXECUTE ANOTHER ACTION BEFORE ANOTHER PDF CAN BE STREAMED BACK TO BROWSER.
sout.write(reportBuffer);

//sout.flush(); //tried these two lines to avoid above error
//sout.close(); //but no improvement.

}
return mapping.findForward(Forwards.REPORT_PAGE);
}//end of performaction
}//end of ReportAction



thanks in advance

Srinivas

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to