You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Karachiwala, Aslam" <As...@ThomsonMedia.com> on 2003/05/06 18:01:08 UTC

Writing to ServletOutputStream from within a Composite JSP

Apologies if this is a duplicate post. My attempts to post last night don't
seem to have succeeded.

I'm migrating...
...from: Struts 1.0.1; JRun 3.1 (Servlet2.2, JSP 1.1)
...to: Struts 1.1-rc1; JRun 4 (Servlet 2.3, JSP 1.2)

The following JSP, which worked with the old versions of the software,
breaks with the new. The "/report.go" include action below involves runtime
XML/XSLT transformation with the output being written to the
ServletOutputStream, which I get via response.getOutputStream(). This call
is now throwing an IllegalStateException presumably because the JSP has
already called response.getWriter() to write the content that's included
before the offending include. I guess this is standard behavior even though
the earlier versions didn't behave this way. Be that as it may, can anyone
suggest how I might be able to combine the output of runtime XML/XSLT
transformations with other dynamic content in a single Composite JSP?

Thanks.

--aslam
===============================================================
<%@ page info="Single-Company Report View" language="java" %>

<%@ include file="/pg/insHeader.jsp" %>
<%@ include file="/pgmod/reports/inc_reportView.jsp" %>

<html>
<head>
	<title><%= _appTitle %>: Report</title>
	<base href="<%= _baseHref %>" />
	<link rel="stylesheet" type="text/css" href="<%= _genericCSS %>" />
</head>

<body>

<%-- Tabs, Bread-Crumb Trail & XLS/PRN links appear only if format="BROWSER"
--%>
<logic:equal name="reportInfo" scope="session" property="format_BROWSER"
value="true">
<jsp:include page="/nav.go" flush="true">
	<jsp:param name="cmd" value="displayTabs"/>
</jsp:include>

<div align="center">
<table class="bcTrail">
<tr>
	<td class="bcTrail" align="left">
	  <jsp:include page="/pgmod/reports/coBCTrail.jsp" flush="true" />
	</td>
	<td align="right" NOWRAP>
	  <jsp:include page="/pgmod/reports/coFormatLinks.jsp" flush="true"
/>
	</td>
</tr>
</table>

<%-- Listbox of cos. in active co. list --%>
<jsp:include page="/pgmod/reports/hlt/mcoListbox.jsp" flush="true" />

</div>
</logic:equal>
<%-- ----------------------------------------------------------------------
--%>

<jsp:include page="/report.go" flush="true">
	<jsp:param name="cmd" value="displayCoReport" />
</jsp:include>
</div>


<req:equalsParameter name="reportID" value="false" match="coTear">
  <br />
  <%@ include file="/web/hltReportFooter.html" %>
</req:equalsParameter>



</body>
</html>
===============================================================

RE: Writing to ServletOutputStream from within a Composite JSP

Posted by Robert Taylor <rt...@mulework.com>.
Just a guess, but try adding flush="false" to all includes prior to
the one for /report.go.

robert

> -----Original Message-----
> From: Karachiwala, Aslam [mailto:Aslam.Karachiwala@ThomsonMedia.com]
> Sent: Tuesday, May 06, 2003 12:01 PM
> To: 'struts-user@jakarta.apache.org'
> Subject: Writing to ServletOutputStream from within a Composite JSP
>
>
> Apologies if this is a duplicate post. My attempts to post last
> night don't
> seem to have succeeded.
>
> I'm migrating...
> ...from: Struts 1.0.1; JRun 3.1 (Servlet2.2, JSP 1.1)
> ...to: Struts 1.1-rc1; JRun 4 (Servlet 2.3, JSP 1.2)
>
> The following JSP, which worked with the old versions of the software,
> breaks with the new. The "/report.go" include action below
> involves runtime
> XML/XSLT transformation with the output being written to the
> ServletOutputStream, which I get via response.getOutputStream(). This call
> is now throwing an IllegalStateException presumably because the JSP has
> already called response.getWriter() to write the content that's included
> before the offending include. I guess this is standard behavior
> even though
> the earlier versions didn't behave this way. Be that as it may, can anyone
> suggest how I might be able to combine the output of runtime XML/XSLT
> transformations with other dynamic content in a single Composite JSP?
>
> Thanks.
>
> --aslam
> ===============================================================
> <%@ page info="Single-Company Report View" language="java" %>
>
> <%@ include file="/pg/insHeader.jsp" %>
> <%@ include file="/pgmod/reports/inc_reportView.jsp" %>
>
> <html>
> <head>
> 	<title><%= _appTitle %>: Report</title>
> 	<base href="<%= _baseHref %>" />
> 	<link rel="stylesheet" type="text/css" href="<%= _genericCSS %>" />
> </head>
>
> <body>
>
> <%-- Tabs, Bread-Crumb Trail & XLS/PRN links appear only if
> format="BROWSER"
> --%>
> <logic:equal name="reportInfo" scope="session" property="format_BROWSER"
> value="true">
> <jsp:include page="/nav.go" flush="true">
> 	<jsp:param name="cmd" value="displayTabs"/>
> </jsp:include>
>
> <div align="center">
> <table class="bcTrail">
> <tr>
> 	<td class="bcTrail" align="left">
> 	  <jsp:include page="/pgmod/reports/coBCTrail.jsp" flush="true" />
> 	</td>
> 	<td align="right" NOWRAP>
> 	  <jsp:include page="/pgmod/reports/coFormatLinks.jsp" flush="true"
> />
> 	</td>
> </tr>
> </table>
>
> <%-- Listbox of cos. in active co. list --%>
> <jsp:include page="/pgmod/reports/hlt/mcoListbox.jsp" flush="true" />
>
> </div>
> </logic:equal>
> <%--
> ----------------------------------------------------------------------
> --%>
>
> <jsp:include page="/report.go" flush="true">
> 	<jsp:param name="cmd" value="displayCoReport" />
> </jsp:include>
> </div>
>
>
> <req:equalsParameter name="reportID" value="false" match="coTear">
>   <br />
>   <%@ include file="/web/hltReportFooter.html" %>
> </req:equalsParameter>
>
>
>
> </body>
> </html>
> ===============================================================
>


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org