wood burning stoves 2.0*
The moose likes Struts and the fly likes struts action and JSP chaining Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts action and JSP chaining" Watch "struts action and JSP chaining" New topic
Author

struts action and JSP chaining

suu boy
Greenhorn

Joined: Apr 06, 2005
Posts: 1
Hi their,
presently i am using struts to send dynamically generated PDF files to browser , struts is the web framework I am using , along with PDF file I would like to display JSP content also , to achieve this I am setting the content of PDF file in action class and forwarding request to some preconfigured jsp file where remaining page content will be generated , I am getting following exception when request reaches my JSP pages

exception content="[OutputStream already obtained]: java.lang.IllegalStateException: OutputStream already obtained"


here is the code snippest in action calss

public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
OutputStream sos=null;
logger.debug("Writing PDF Stream...............");
StringBuffer sbFilename = new StringBuffer();
sbFilename.append("filename_");
sbFilename.append(System.currentTimeMillis());
sbFilename.append(".pdf");
this.getResponse();
getResponse().setContentType("application/pdf");
getResponse().setHeader("Content-Disposition", "attachment; filename=\"PurchaseOrder.pdf\"");
byte[] tmpData = baosPDF.toByteArray();
System.out.println("Data Retrieved.." + tmpData.length);
sos = getResponse().getOutputStream();
sos.write(tmpData);
sos.close();
logger.debug("completed writing PDF Stream...............");



//some code..................
// some code ...........................
return forward;
}


can any one help out to resolve this issue , I would like to write some data response stream at action classes and again I want to add jsp dynamic content to response stream,
yes i am talking about kind of servlet chaining in struts,
how can i avoid this exception and achieve my goal

with regards,
Suhi...............
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: struts action and JSP chaining