• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

struts action and JSP chaining

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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...............
 
A tiny monkey bit me and I got tiny ads:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic