File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts action and JSP chaining" Watch "struts action and JSP chaining" New topic

struts action and JSP chaining

suu boy

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();
getResponse().setHeader("Content-Disposition", "attachment; filename=\"PurchaseOrder.pdf\"");
byte[] tmpData = baosPDF.toByteArray();
System.out.println("Data Retrieved.." + tmpData.length);
sos = getResponse().getOutputStream();
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,
I agree. Here's the link:
subject: struts action and JSP chaining
jQuery in Action, 3rd edition