On Thu, 10 Jan 2002, Todd Kaplinger wrote: > Date: Thu, 10 Jan 2002 17:01:50 -0500 > From: Todd Kaplinger <[EMAIL PROTECTED]> > Reply-To: Tomcat Users List <[EMAIL PROTECTED]>, > [EMAIL PROTECTED] > To: [EMAIL PROTECTED] > Subject: ServletResponseWrapperInclude.getOutputStream > > Hello List, > > I am currently working with Tomcat 4.0 and am encountering a problem with > the following... > > <jsp:include page="someServlet" flush="true"/> > where someServlet is attaining an OutputStream instead of the standard > PrintWriter. > > By reviewing the source code, I see that with the jsp 1.2 specification, > ServletResponseWriterInclude uses the PrintWriter used by the initial > calling jsp to buffer the response (for implementing flush=false). > > The question is should one be able to still use OutputStreamWriter in > conjunction with includes? If no, then why? >
There is a general principle here: the includING and includED servlet (or JSP page) *must* use the same type of output -- either binary via response.getOutputStream() or character via response.getWriter(). Violating this rule will trigger an IllegalStateException. The second principle to remember is that JSP *always* uses the response.getWriter() approach, because it is designed solely for character based output. The implications of this is that you will not be able to use <jsp:include> to include a component that generates output via response.getOutputStream(). It doesn't actually matter if the "outer" component is a JSP page, or a servlet that calls getWriter(). > Thank you. > Craig -- To unsubscribe: <mailto:[EMAIL PROTECTED]> For additional commands: <mailto:[EMAIL PROTECTED]> Troubles with the list: <mailto:[EMAIL PROTECTED]>
