You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Eric Dalquist <er...@doit.wisc.edu> on 2008/05/12 19:08:44 UTC

Missing Context error text

Is it expected that when attempting a cross-context dispatch to a 
missing context that error text is written to the PrintWriter of the 
underlying HttpServletResponse?

I wrap the response before the dispatch with an extension of 
HttpServletResponseWrapper which redirects all content (PrintWriter or 
ServletOutputStream) to a buffer for later use. This works correctly if 
the context being dispatched to exists, all content written out by the 
call ends up in my buffer. If the context doesn't exist Tomcat writes 
out an error message to the PrintWriter of the wrapped 
HttpServletResponse which results in the message like "The requested 
resource (/MyContext/MyServlet) is not available" appearing in my 
rendered page where I don't want it.

Is this behavior, writing to the underlying response object, dictated by 
the spec? Is this required of Tomcat versus writing to the PrintWriter 
provided by the response wrapper.


Thank you,
-Eric Dalquist

Re: Missing Context error text

Posted by Mark Thomas <ma...@apache.org>.
Eric Dalquist wrote:
> Is this behavior, writing to the underlying response object, dictated by 
> the spec? Is this required of Tomcat versus writing to the PrintWriter 
> provided by the response wrapper.

Not that I can see in the spec. Also, my quick test shows that the 
DefaultServlet (which creates the missing resource message) calls 
getWriter() on the wrapped response object as expected. It is possible you 
are missing a wrapper somewhere?

If not, if you create a new bug and attach the simplest test case that 
demonstrates the issue (two classes: a wrapper and a servlet should be 
enough) I'll take a closer look.

BTW, if you don't like the message, using your own DefaultServlet (eg the 
Tomcat one less the few lines of code that write the message) would be a 
way around it.

Mark


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org