tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Frydl <>
Subject Returning status 500 and data from servlet
Date Thu, 28 Dec 2000 10:59:46 GMT

    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)


    HTML informing about internal server error

    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

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


View raw message