Jeff,
Thanks for responding. You write: "
>Just curious.. why would setting the content length affect the buffer size?
>Aren't you thinking of response.setBufferSize(int $1)?
I changed my code to utilize response.setBufferSize(int). Nothing changed -
still the code works in two directories but not in another. I find though,
that in my jsp code, I can call response.setBuffer(int) but it does not
affect the size of the JSP Writer out buffer size. A call to
out.getRemaining() returns the same value it did before (7234 bytes). How
can I change the buffer size of the JSP writer - I don't find a method in
the JSPWriter API. The JSPBuffer(bufSize, boolean) constructor is protected.
Can I change the JSPWriter's buffer size in my <jsp:include ...> action?
>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.
My dataset size isn't changing. I am utilizing identical JSP and Servlet
code calling the same dataset. It seems only to be dependent upon from what
webapp directory (context?) I call the jsp from.
>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.
It seems the erroring jsp bombs prior to the actual <jsp:include> directive.
I have System.out.printlns in the called Servlet - none of these printlns
are produced in the Tomcat console prior to the Exception message. The
Exception text follows:
Internal Servlet Error:
javax.servlet.ServletException: Servlet Exception
at org.apache.tomcat.core.Handler.service(Handler.java:307)
at
org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
at
org.apache.tomcat.facade.RequestDispatcherImpl.include(RequestDispatcherImpl
.java:345)
at
org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.java:414)
at
BenchMgmt.Associates.Tim_0005fHengst._0002fBenchMgmt_0002fAssociates_0002fTi
m_0005fHengst_0002fxslTransform_0002ejspxslTransform_jsp_3._jspService(_0002
fBenchMgmt_0002fAssociates_0002fTim_0005fHengst_0002fxslTransform_0002ejspxs
lTransform_jsp_3.java:123)
at
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.ja
va:177)
at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:318)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:391)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
at org.apache.tomcat.core.Handler.service(Handler.java:286)
at
org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
at
org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:79
7)
at
org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
at
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpC
onnectionHandler.java:210)
at
org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
at
org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
at java.lang.Thread.run(Thread.java:484)
Root cause:
java.lang.IllegalStateException: Response has already been committed
at
org.apache.tomcat.facade.HttpServletResponseFacade.sendError(HttpServletResp
onseFacade.java:204)
at javax.servlet.http.HttpServlet.doGet(HttpServlet.java:232)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
at org.apache.tomcat.core.Handler.service(Handler.java:286)
at
org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
at
org.apache.tomcat.facade.RequestDispatcherImpl.include(RequestDispatcherImpl
.java:345)
at
org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.java:414)
at
BenchMgmt.Associates.Tim_0005fHengst._0002fBenchMgmt_0002fAssociates_0002fTi
m_0005fHengst_0002fxslTransform_0002ejspxslTransform_jsp_3._jspService(_0002
fBenchMgmt_0002fAssociates_0002fTim_0005fHengst_0002fxslTransform_0002ejspxs
lTransform_jsp_3.java:123)
at
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.ja
va:177)
at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:318)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:391)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
at org.apache.tomcat.core.Handler.service(Handler.java:286)
at
org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
at
org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:79
7)
at
org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
at
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpC
onnectionHandler.java:210)
at
org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
at
org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
at java.lang.Thread.run(Thread.java:484)
Still trying to figure this one out! Could it be a bug????
RSVP,
Tim
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Thursday, March 15, 2001 4:37 PM
To: [EMAIL PROTECTED]
Subject: Re: Please help!!: Inconsistent "Response already committed"
excepti on
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
>