tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Frydl <mar...@idoox.com>
Subject Returning status 500 and data from servlet
Date Wed, 27 Dec 2000 15:43:28 GMT
Hi,

    I need to return HTTP 500 from servlet along with some usable data,
but Tomcat (4.0 m4&5) adds its own data.

    Here is my code fragment:

    resp.setStatus (resp.SC_INTERNAL_SERVER_ERROR);
    resp.setContentType ("text/xml");
    Writer wrt=resp.getWriter ();
    wrt.write (message);
    wrt.close ();

    If this is used, Tomcat returns:

    HTTP/1.1 500 Internal Server Error
    Content-Type: text/xml
    Date: Wed, 27 Dec 2000 13:41:07 GMT
    Transfer-Encoding: chunked
    Server: Apache Tomcat/4.0-dev (HTTP/1.1 Connector)

    2d3
    text...
    0

    <html>
    HTML informing about internal server error
    </html>

    If wrt.close () is omitted, chunked text and HTML are reversed in
milestone 4, milestone 5 omits my text completely. In this case
HttpURLConnection class hangs - probably expected chunk length but got
<html>...

    How can I tell Tomcat not to include its own message about error
(that HTML)?

    Martin


Mime
View raw message