tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nathan Potter <>
Subject Re: Tomcat returns HTTP status of 200 when HttpServletResponse.sendError() called.
Date Tue, 13 Jan 2009 00:58:24 GMT

On Jan 12, 2009, at 3:34 PM, Caldarale, Charles R wrote:

> Don't think so.  Does your code happen to call  
> response.setStatus(200) somewhere along the way?
> - Chuck

Well at first I didn't think so, but now I am wondering....

After adding some more instrumentation I have determined that I am  
inadvertently setting the status to 200.

I was replicating the problem with this servlet:

package opendap.experiments;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletRequest;

public class SendErrorTest extends HttpServlet {

     public void doGet(HttpServletRequest request,
                       HttpServletResponse response) {
         try {

         catch (Exception e) {

And a simple document service servlet:


With this error-page:


I added some instrumentation and looked at the logs and saw that when  
the sendError() method is called in the SendErrorTest servlet the call  
returns immediately. And is followed by a the docs servlet receiving a  
request for the error document, which since it is successfully  
returning a document sets the HTTP status to 200.

Is sendError() using a redirect?

Is there a way to set the value of the <location> element in the error- 
page declaration so that tomcat just grabs the file from the context  

The java servlet spec (2.4) says:

"If the sendError method is called on the response, the container  
consults the
list of error page declarations for the Web application that use the  
syntax and attempts a match. If there is a match, the container  
returns the resource
as indicated by the location entry."

So what does "the container returns the resource as indicated by the  
location entry"  mean for tomcat?

Is there an example of a design pattern you can point me to?



= = =
Nathan Potter                        ndp at
OPeNDAP, Inc.                        541.752.1852

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message