On Thu, Mar 15, 2001 at 02:44:32PM -0500, Tim Hengst wrote:
> Please help me resolve this problem.  I've tried comparing generated code to
> no avail - the only difference is the package statement.
> 
> I call an xslt servlet (that returns formatted html output to the JSP
> response Writer)  via a <jsp:include> action from a jsp page,
> xsltTransform.jsp.
> If I put the same xsltTransform.jsp page in different Tomcat web application
> directories, in one it runs, in another I get a "Response already committed"
> error when the servlet tries to write to the response Writer.
> 
> In the case where the jsp page runs, a call to response.isCommitted() within
> the servlet, prior to the XSLT transformation writing to the JSP Writer,
> returns true (due to the automatic flush prior to the
> pageContextImpl.include() call) .
> 
> Has anybody run into this before?  What determines whether a committed
> response object can be flushed or written to without a  "response committed"
> error?  (I have set the contentLength of the response object to prevent
> writing due to buffer overflow).

Just curious.. why would setting the content length affect the buffer size?
Aren't you thinking of response.setBufferSize(int $1)?

I once had exactly your symptoms (inconsistent "Response already committed"),
and it was because my response buffer was too small (see JSP's "page
directive"). Because the amount of data I was pulling with <jsp:include>
varied, the problem appeared to be inconsistent.

Which line exactly causes the "Response already committed" error? Are you
trying a response.sendRedirect() or something? Usually you can flush as much as
you want during your servlet/JSP. The only time it causes probs is, eg, with
sendRedirect() calls.


HTH,

--Jeff

> Here are the guts of my servlet doGet() code:
> // Assume size of html output will be 1.5 times the size of the dataSetSize
>           dataSetSize *= 1.5;
> 
>           response.setContentLength(dataSetSize);
> 
>         // Process the transformation.
>           if(response.isCommitted()){
>                 System.out.println("*****  WARNING 2:  Response is committed
> prior to XSLT call.  Flushing writer.  *****");
>                 response.getWriter().flush();
>           }
>         try {
>               XSLTProcessor processor = XSLTProcessorFactory.getProcessor();
> 
>                   processor.process( new XSLTInputSource( dataInputStream ),
> 
>                                new XSLTInputSource( stylesheetInputStream ),
>                                          new XSLTResultTarget(
> (java.io.Writer )response.getWriter() ) );
> 
>         }
> 
> Here is my xsltTransform.jsp code:
> 
> if(request.getParameter("list")!=null){
>                                 String list = request.getParameter("list");
>                         %>
>                                 <BR><BR><b><%=list%> List:  </b><BR>
>                         <%      if(list.equals("Associates")){%>
> 
>                                 <jsp:include
> page="/servlet/development.util.XSLTServlet?list=Associates&xslFileName=d:\\
> training\\development\\data\\associates.xsl&xmlFileName=d:\\training\\develo
> pment\\data\\brp.xml&clientURL=/beach/jsp/xslTransform.jsp?list=Associates&g
> etResults=false" flush="true"/>
> 
>                         <%      }
> 
> Please RSVP!
> 
> Thanks,
> 
> Tim Hengst
> Tampa, FL
> 

Reply via email to