tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ben Sifuentes" <ben.sifuen...@intechpro.com>
Subject java.lang.IllegalStateException when using RequestDispatcher.include(...)
Date Wed, 17 Oct 2001 04:22:27 GMT
Can some explain why this is happening and how to fix it?

I'm receiving the following error:

java.lang.IllegalStateException: Cannot forward as OutputStream or Writer
has already been obtained
	at
org.apache.tomcat.facade.RequestDispatcherImpl.doForward(RequestDispatcherIm
pl.java:178)
	at
org.apache.tomcat.facade.RequestDispatcherImpl.forward(RequestDispatcherImpl
.java:162)
	at PurchReq.service(PurchReq.java:50)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:405)
	at org.apache.tomcat.core.Handler.service(Handler.java:287)
	at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
	at
org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:81
2)
	at org.apache.tomcat.core.ContextManager.service(ContextManager.java:758)
	at
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpC
onnectionHandler.java:213)
	at
org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
	at
org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:501)
	at java.lang.Thread.run(Thread.java:484)


Note: If I comment out the rd.include(...) call below everything works fine.

My understanding of this was that by using the include(..) keeps the
execution of the servlet within the same context of the original.

The Servlet code executes the following:

  public void service(HttpServletRequest req,
		      HttpServletResponse res)
      throws ServletException, IOException {

      RequestDispatcher rd;

      // Runs the configuration component
      rd = req.getRequestDispatcher("Configurator");
      rd.include(req, res);

      .
      .
      .

      rd = getServletContext().getRequestDispatcher("/default.jsp");
      rd.forward(req, res);

  }


The Configurator servlet really doesn't do anything at the moment:

public class Configurator extends HttpServlet {
    public void doGet(HttpServletRequest req, HttpServletResponse res)
	throws ServletException, IOException {

	.
	.
	.
    }
}


Any help would be appreciated!!

Thanks,
-Ben


Mime
View raw message