• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

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...............
 
I've been selected to go to the moon! All thanks to this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic