IllegalStateException: Header already sent

Applies to:


Description:
Error while trying to set a header after writing an entry to the ouput stream of the response.

Cause:
When the content of the response is already written, headers cannot be longer set.

admin JAVA-Servlets

  1. admin
    March 9th, 2009 at 18:22 | #1

    Set the header before writing an entry to the output stream.

    Example:
    response.setContentType(“text/html”);
    OutputStream out = response.getOutputStream();
    out.writeln(“Test”);
    out.flush();

  1. No trackbacks yet.