You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@jakarta.apache.org by Nick Gilliam d-3712 7-5554 ng96753 gillidn <gi...@faith.maf.nasa.gov> on 2000/02/08 17:38:51 UTC

JSP error using

When using the <jsp:include> tag to include a servlet which works with JServSSI, we get the following error.  We are new to jsp.  Any help in resolving this bug is greatly appreciated.


Goodbye World 

Included servlet error: 500: Internal Servlet Error:

java.lang.IllegalStateException: Writer is already being used for this request
        at java.lang.Throwable.fillInStackTrace(Native Method)
        at java.lang.Throwable.fillInStackTrace(Compiled Code)
        at java.lang.Throwable.(Compiled Code)
        at java.lang.Exception.(Compiled Code)
        at java.lang.RuntimeException.(Compiled Code)
        at java.lang.IllegalStateException.(Compiled Code)
        at org.apache.tomcat.core.ResponseImpl.getOutputStream(Compiled Code)
        at org.apache.tomcat.core.HttpServletResponseFacade.getOutputStream(Compiled Code)
        at qis.servlets.LastUpdate.doGet(LastUpdate.java:29)
        at javax.servlet.http.HttpServlet.service(Compiled Code)
        at javax.servlet.http.HttpServlet.service(Compiled Code)
        at org.apache.tomcat.core.ServletWrapper.handleInvocation(Compiled Code)
        at org.apache.tomcat.core.ServletWrapper.handleRequest(Compiled Code)
        at org.apache.tomcat.servlets.InvokerServlet.service(InvokerServlet.java:240)
        at javax.servlet.http.HttpServlet.service(Compiled Code)
        at org.apache.tomcat.core.ServletWrapper.handleInvocation(Compiled Code)
        at org.apache.tomcat.core.ServletWrapper.handleRequest(Compiled Code)
        at org.apache.tomcat.core.RequestDispatcherImpl.include(RequestDispatcherImpl.java:249)
        at org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.java:348)
        at _0002fhello_0005fworld_0002ejsphello_0005fworld_jsp_5._jspService(_0002fhello_0005fworld_0002ejsphello_0005fworld_jsp_5.java:72)
        at org.apache.jasper.runtime.HttpJspBase.service(Compiled Code)
        at javax.servlet.http.HttpServlet.service(Compiled Code)
        at org.apache.jasper.runtime.JspServlet$JspServletWrapper.service(Compiled Code)
        at org.apache.jasper.runtime.JspServlet.serviceJspFile(Compiled Code)
        at org.apache.jasper.runtime.JspServlet.service(Compiled Code)
        at javax.servlet.http.HttpServlet.service(Compiled Code)
        at org.apache.tomcat.core.ServletWrapper.handleInvocation(Compiled Code)
        at org.apache.tomcat.core.ServletWrapper.handleRequest(Compiled Code)
        at org.apache.tomcat.core.ContextManager.service(Compiled Code)
        at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(Compiled Code)
        at org.apache.tomcat.service.TcpConnectionThread.run(Compiled Code)
        at java.lang.Thread.run(Compiled Code)


Thanks,
Nick

Re: JSP error using

Posted by Rachel Greenham <ra...@enetgroup.co.uk>.
Fergus Gallagher wrote:
> 
> This can happen when you try to grab the ServletOutputStream after
> something else has written to it.   For example an error handler which
> tries to reopen the output stream in the middle of a request.
> 
> A way to get around this might be to write to a StringWriter and then only
> print this to the ServletOutputStream when you know you are ok.

Yes, that's reasonable. The problem is that this particular JSP happens not
to have any Java code fragments (scriptlets) in it, it's just HTML with some
jsp:include tags to include header and footer etc, so I'm pretty sure I'm
not grabbing any output streams in my own code. :-) All the more complicated
JSPs with lots of code in them are working fine BTW. I was migrating the
site up from JRun 2.3.3 (Servlet 2.1, JSP 1.0) and pretty much the only
thing I've been having to do so far apart from overall site config is extend
the jsp:include tags to include 'flush="true"' - but that seems to be what's
causing the trouble here, but it's mandatory I see. Looking at the exception
stacktrace, it looks like it's being thrown from the jsp:include tag handler
during it's flush() method.

BTW, I now know that Enhydra 3.0.1 uses Tomcat 3.0, so it's possible this is
something that was fixed by 3.1? :-)

-- 
Rachel

Re: JSP error using

Posted by Fergus Gallagher <Fe...@OrbisUK.com>.
This can happen when you try to grab the ServletOutputStream after 
something else has written to it.   For example an error handler which 
tries to reopen the output stream in the middle of a request.

A way to get around this might be to write to a StringWriter and then only 
print this to the ServletOutputStream when you know you are ok.

Fergus

At 16:55 12/05/00 +0100, you wrote:
>Nick Gilliam d-3712 7-5554 ng96753 gillidn wrote:
> >
> > When using the <jsp:include> tag to include a servlet which works with 
> JServSSI, we get the following error.  We are new to jsp.  Any help in 
> resolving this bug is greatly appreciated.
> >
> > Goodbye World
> >
> > Included servlet error: 500: Internal Servlet Error:
> >
> > java.lang.IllegalStateException: Writer is already being used for this 
> request
>
>... etc...
>
>Did you or anyone else ever come up with an answer to this one? Only I'm
>getting it now, albeit that I'm using Enhydra 3.01, which has Tomcat
>built-in (don't know which version). Slight difference is that the error now
>says "OutputStream is already being used for this request".
>
>What's interesting is that most of my JSPs are fine, but the particular one
>I'm getting this on has only got normal HTML and the jsp:include tags; no
>scriptlets or defined tags. If I remove the jsp:include tags, it works fine,
>but if I put a scriptlet in ("<% out.println("Hello!"); %>"), it still
>fails, so I don't know the pattern here.
>
>The exception actually occurs during the final out.flush(); in the finally{}
>block of the generated Java source.
>
>--
>Rachel
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: general-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: general-help@jakarta.apache.org

--
Fergus Gallagher
Orbis
http://www.orbisuk.com/
+44-(0)20-8987 0717


Re: Enhydra: Re: JSP error using

Posted by Rachel Greenham <ra...@enetgroup.co.uk>.
Rachel Greenham wrote:
> 
> Peter Johnson wrote:
> >
> > Rachel,
> >   Can you post some more information about this bug? If possible I'd like to see
> > the complete JSP's that caused the problem.
> 
> Sure, hang on...

[snip]

I've found out something else. I just tried, on a complete offchance,
putting in a newline character before the first <jsp:include .../> tag and
the page works fine now. It seems to be unhappy if <jsp:include ... /> is
the very first thing in a JSP script.

So, it is a bug in Tomcat/Jasper, but hopefully not a hard one to track down
now. :-)

-- 
Rachel

Re: JSP error using

Posted by Rachel Greenham <ra...@enetgroup.co.uk>.
Nick Gilliam d-3712 7-5554 ng96753 gillidn wrote:
> 
> When using the <jsp:include> tag to include a servlet which works with JServSSI, we get the following error.  We are new to jsp.  Any help in resolving this bug is greatly appreciated.
> 
> Goodbye World
> 
> Included servlet error: 500: Internal Servlet Error:
> 
> java.lang.IllegalStateException: Writer is already being used for this request

... etc...

Did you or anyone else ever come up with an answer to this one? Only I'm
getting it now, albeit that I'm using Enhydra 3.01, which has Tomcat
built-in (don't know which version). Slight difference is that the error now
says "OutputStream is already being used for this request".

What's interesting is that most of my JSPs are fine, but the particular one
I'm getting this on has only got normal HTML and the jsp:include tags; no
scriptlets or defined tags. If I remove the jsp:include tags, it works fine,
but if I put a scriptlet in ("<% out.println("Hello!"); %>"), it still
fails, so I don't know the pattern here.

The exception actually occurs during the final out.flush(); in the finally{}
block of the generated Java source.

-- 
Rachel