opendap/dtswar/src/main/java/opendap/dts/DTSServlet.java
public void IOExceptionHandler(IOException e, ReqState rs)
    {
        HttpServletResponse response = rs.getResponse();
        try {
            BufferedOutputStream eOut = new BufferedOutputStream(response.getOutputStream());
            response.setHeader("Content-Description", "dods-error");

            // This should probably be set to "plain" but this works, the
            // C++ slients don't barf as they would if I sent "plain" AND
            // the C++ don't expect compressed data if I do this...
            response.setHeader("Content-Encoding", "");

            // Strip any double quotes out of the parser error message.
            // These get stuck in auto-magically by the javacc generated parser
            // code and they break our error parser (bummer!)
            String msg = e.getMessage();
            if(msg != null)
                msg = msg.replace('\"', '\'');

            DAP2Exception de2 = new DAP2Exception(opendap.dap.DAP2Exception.CANNOT_READ_FILE, msg);
            de2.print(eOut);

            if(Debug.isSet("showException")) { // Error message
                log.error("DODServlet ERROR (IOExceptionHandler): " + e);
                log.error(rs.toString());
                if(track) {
                    RequestDebug reqD = (RequestDebug) rs.getUserObject();
                    log.error("  request number: " + reqD.reqno + " thread: " + reqD.threadDesc);
                }
                printThrowable(e);
            }

        } catch (IOException ioe) {
            log.error("Cannot respond to client! IO Error: " + ioe.getMessage());
        }

    }
public void IOExceptionHandler(IOException e, ReqState rs)
    {
        HttpServletResponse response = rs.getResponse();
        try {
            BufferedOutputStream eOut = new BufferedOutputStream(response.getOutputStream());
            response.setHeader("Content-Description", "dods-error");

            // This should probably be set to "plain" but this works, the
            // C++ slients don't barf as they would if I sent "plain" AND
            // the C++ don't expect compressed data if I do this...
            response.setHeader("Content-Encoding", "");

            // Strip any double quotes out of the parser error message.
            // These get stuck in auto-magically by the javacc generated parser
            // code and they break our error parser (bummer!)
            String msg = e.getMessage();
            if(msg != null)
                msg = msg.replace('\"', '\'');

            DAP2Exception de2 = new DAP2Exception(opendap.dap.DAP2Exception.CANNOT_READ_FILE, msg);
            de2.print(eOut);

            if(Debug.isSet("showException")) { // Error message
                log.error("DODServlet ERROR (IOExceptionHandler): " + e);
                log.error(rs.toString());
                if(track) {
                    RequestDebug reqD = (RequestDebug) rs.getUserObject();
                    log.error("  request number: " + reqD.reqno + " thread: " + reqD.threadDesc);
                }
                printThrowable(e);
            }

        } catch (IOException ioe) {
            log.error("Cannot respond to client! IO Error: " + ioe.getMessage());
        }

    }
Sends an error to the client.
fix: The problem is that if the message is already committed when the IOException occurs, the headers dont get set.

@param e  The exception that caused the problem.
@param rs The <code>ReqState</code> for the client.