Here is some more info on this problem.  I'm seem to be having some problems
with the respnse getting committed too early.  It still seems wrong that an
error page ever get returned with status code 200 though.

1) client makes request to Tomcat
2) Tomcat calls service() on my main servlet
3) servlet does an include() on some (possibly non-existant) JSP
4) JSP file does not exist (expected)
5) FileNotFoundException thrown from include()
6) main servlet catches exception
7) main servlet calls sendError()
8) sendError throws IllegalStateException (response already committed)
9) my error servlet gets called
10) error page get generated and sent to client with HTTP status 200 OK

The RequestDispatcher.include() method calls flushBuffer(), which commits the
response.  This seems to mean that if you have a servlet which includes a JSP,
any errors that occur can never be handled properly.  Yikes!

Code comments indicate that this flushBuffer() is not required by the spec, but
is instead there to work around a problem with the session interceptor (BugRat
bug #316).

--
Ethan

-----Original Message-----
From: Ethan Wallwork [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 28, 2001 1:03 PM
To: Tomcat-Dev
Subject: HTTP Status Codes and Error Pages



I can't tell if this is a bug or intended behavior:

I have a servlet that acts as the error page for my webapp.  Note that this is
set up using the web.xml file, not the errorPage directive in the JSPs (if that
makes any difference?)

When there is an error (say 500 Internal Server Error), it returns a WML page
saying things went wrong.   This page is being properly generated, but the HTTP
response code being sent along with it is "200 OK"!

The request attribute java.servlet.error.status_code is set to 500, as I would
expect.  Calling response.setStatus(500) in the error servlet changes nothing.

This is the response I get, headers included:

HTTP/1.0 200 OK
Content-Type: text/vnd.wap.wml;charset=UTF-8
Cache-Control: no-cache
Servlet-Engine: Tomcat Web Server/3.2 (final) (JSP 1.1; Servlet 2.2; Java
1.3.0; SunOS 5.8 sparc; java.vendor=Sun Microsystems Inc.)

<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<card title="Error 500" id="error">
<do label="Back" type="prev">
<prev/>
</do>
<p>
We're sorry, your request could be fulfilled.
<br/>
500 Internal Server Error
</p>
</card>
</wml>



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

Reply via email to