Return-Path: Delivered-To: apmail-xml-cocoon-users-archive@xml.apache.org Received: (qmail 10084 invoked by uid 500); 27 Mar 2001 11:40:36 -0000 Mailing-List: contact cocoon-users-help@xml.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: cocoon-users@xml.apache.org Delivered-To: mailing list cocoon-users@xml.apache.org Received: (qmail 10045 invoked from network); 27 Mar 2001 11:40:33 -0000 Sender: ulim@denic.de Message-ID: <3AC0995A.C55DCFB5@denic.de> Date: Tue, 27 Mar 2001 13:44:58 +0000 From: Ulrich Mayring X-Mailer: Mozilla 4.75 [en] (X11; U; Linux 2.2.16-22 i686) X-Accept-Language: en MIME-Version: 1.0 To: cocoon-users@xml.apache.org Subject: Suggestion for Frontend.java X-MIMETrack: Itemize by SMTP Server on notes/Denic(Release 5.0.4 |June 8, 2000) at 27.03.2001 13:40:13, Serialize by Router on notes/Denic(Release 5.0.4 |June 8, 2000) at 27.03.2001 13:40:15, Serialize complete at 27.03.2001 13:40:15 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii X-Spam-Rating: h31.sny.collab.net 1.6.2 0/1000/N Hi folks, As of 1.8.2 we have this code: public static void print(ServletResponse response, String title, String message) throws IOException { response.setContentType("text/html"); PrintWriter out = new PrintWriter(response.getWriter()); header(out, 80); out.println("

" + title + "

"); if (message != null) out.println("
" + message +
"
"); footer(out); } I think it would be useful to introduce an additional try/catch Block like this: public static void print(ServletResponse response, String title, String message) throws IOException { response.setContentType("text/html"); try { PrintWriter out = new PrintWriter(response.getWriter()); ... yaddayadda ... } catch (IllegalStateException e) { OutputStream out = response.getOutputStream(); out.write("

" + title + "

".getBytes()); ... yaddayadda ... out.flush (); } } The thing is this method is supposed to print out an error that occurred somewhere. Now suppose that error has something to do with an XSP page calling response.getOutputStream() and outputting something by itself. Then in the current code an exception is thrown by response.getWriter() saying that getOutputStream() has already been called. The original error, however, is lost since no output can take place. This is actually a very troublesome issue, because I have hundreds of XSP pages here that could potentially be the culprit, but I can't point my finger on it, because I never see Cocoon's error message. I do have the exception in my servlet log, but that doesn't tell me much. I am pasting it below, just in case someone is interested. The exception occurs every minute or so and we have so much traffic here that I really can't tell who causes it. The same enhancement could be applied to the status method, but I think it's not necessary, because that method just builds the Cocoon status page and there's no way to call getOutputStream() before that. Other than that there is no place in Cocoon's source code that calls response.getWriter() Ulrich java.lang.IllegalStateException: Already called getOutputStream. at java.lang.Throwable.fillInStackTrace(Native Method) at java.lang.Throwable.fillInStackTrace(Compiled Code) at java.lang.Throwable.(Compiled Code) at java.lang.Exception.(Compiled Code) at java.lang.RuntimeException.(Compiled Code) at java.lang.IllegalStateException.(Compiled Code) at org.apache.jserv.JServConnection.getWriter(Compiled Code) at org.apache.cocoon.Frontend.print(Compiled Code) at org.apache.cocoon.Frontend.error(Compiled Code) at org.apache.cocoon.Cocoon.service(Compiled Code) at javax.servlet.http.HttpServlet.service(Compiled Code) at org.apache.jserv.JServConnection.processRequest(Compiled Code) at org.apache.jserv.JServConnection.run(Compiled Code) at java.lang.Thread.run(Compiled Code) -- Ulrich Mayring DENIC eG, Systementwicklung --------------------------------------------------------------------- Please check that your question has not already been answered in the FAQ before posting. To unsubscribe, e-mail: For additional commands, e-mail: