tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Henrik Kniberg <hen...@goyada.com>
Subject Strange behaviour of jsp:include
Date Tue, 25 Jul 2000 14:07:19 GMT
Hi,

Using the <jsp:include> tag I'm running into IllegalStateException
because getOutputStream() gets called twice.

I'm simply including a call from a JSP page to a servlet, like this:

<html>
<body>
<jsp:include page="/servlet/DateServlet" flush="true"> </jsp:include>
</body>
</html>

DateServlet is a trivial servlet that simply prints the current date on
HttpServletRequest.getOutputStream(), it works fine in all other
contexts.  When executing this JSP page I get
"java.lang.IllegalStateException: Writer is already being used for this
request".  I guess the JSP page opens the output stream and then the
date servlet tries to open it as well, which Tomcat apparantely doesn't
like.

Here is the relevant part of the stack trace:

 java.lang.IllegalStateException: Writer is already being used for this
request at
org.apache.tomcat.core.ResponseImpl.getOutputStream(ResponseImpl.java:458)
at
org.apache.tomcat.core.HttpServletResponseFacade.getOutputStream(HttpServletResponseFacade.java:144)

at DateServlet.service(DateServlet.java:44) at
javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java,
Compiled Code) at
org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:597) 
at
org.apache.tomcat.servlets.InvokerServlet.service(InvokerServlet.java:257) 
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at
org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java,
Compiled Code) at
org.apache.tomcat.core.RequestDispatcherImpl.include(RequestDispatcherImpl.java:262) 
at
org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.java:350) 
at
_0002findex_0002ejspindex_jsp_14._jspService(_0002findex_0002ejspindex_jsp_14.java:62) 

I've spent all day trying to figure out a way to dynamically include a
call from a web page to a servlet, i.e. exactly the thing you normally
would use a <servlet> tag for.  I'd like to stick to standards and avoid
<servlet> tags.  Besides, JSSI doesn't seem to work with JSDK2.1.

/Henrik

Mime
View raw message