Wrox Home  
Search P2P Archive for: Go

  Return to Index  

servlets thread: Error when wrapping a response object


Message #1 by Jay Wright <jwright@o...> on Fri, 2 Nov 2001 10:36:26 -0800
Has no one seen this before?  It seems odd that the trick of wrapping the
response to write it to file instead of sending it would cause a problem in
Tomcat where I cannot then do a RequestDispatch forward or a
response.sendRedirect().

I'm surprised no one else has had a similar problem.

> -----Original Message-----
> From: Jay Wright [mailto:jwright@o...]
> Sent: Friday, November 02, 2001 10:36 AM
> To: Servlets
> Subject: [servlets] Error when wrapping a response object
> 
> 
> 
> Hi all,
> 
> I am getting a servlet error which has something to do with a wrapped
> response object.
> 
> With Resin, I have created a servlet that wraps a response 
> object for the
> purpose of writing the response's html to a file.  This complete
> successfully, then the RequestDispatcher forwards the request 
> to a jsp,
> which in effect displays a thank you page.  It works wonderfully.
> 
> When I deploy the same application to Tomcat, I get the 
> following error:
> 
> java.lang.IllegalStateException: Cannot forward after 
> response has been
> committed
>         at 
> org.apache.catalina.core.ApplicationDispatcher.doForward(Unknown
> Source)
>         at 
> org.apache.catalina.core.ApplicationDispatcher.forward(Unknown
> Source)
>         at atonce.mas.web.MainServlet.doGet(MainServlet.java:88)
> 
> Apparently the two servlet containers handle this 
> differently.  As curious
> as this is, I'm more concerned with getting the tomcat 
> version working.  Is
> there anything I can do to "uncommit" the response?  I assume 
> not.  I could
> use a sendRedirect, but would prefer to stick with the 
> RequestDispatchers
> forward method to be consistent and standard with my servlet model.
> 
> Any ideas?
> 
> Thanks,
> Jay
> 
> ---
> SIGS Conference for Java Development  
> Targeted, focused classes, expertise level classes 
> taught by Java gurus, rigorous tutorials, and 
> exhibit floor makes SIGS Conference for Java
> Development a learning experience unlike any 
> other. Join over 10,000 developers and programmers 
> from across the U.S. and around the world who
> have benefited from attending SIGS/101 Conferences.
> http://www.javadevcon.com
> $subst('Email.Unsub')
> 

  Return to Index