The problem is that you are calling getResponse().getOutputStream(), which invokes getOutputSteam from the http servlet response. After handling your request, Wicket calls getWriter from the same response. From the ServletResponse.getOutputStream Javadoc:
"Either this method or getWriter<eclipse-javadoc:%E2%98%82=lpscad/C:%5C/Documents%20and%20Settings%5C/deinf.crk%5C/.m2%5C/repository%5C/javax%5C/servlet%5C/servlet-api%5C/2.5%5C/servlet-api-2.5.jar%3Cjavax.servlet%28ServletResponse.class%E2%98%83ServletResponse%7EgetOutputStream%E2%98%82%E2%98%82getWriter>may be called to write the body, not both." "Throws:IllegalStateException<eclipse-javadoc:%E2%98%82=lpscad/C:%5C/Documents%20and%20Settings%5C/deinf.crk%5C/.m2%5C/repository%5C/javax%5C/servlet%5C/servlet-api%5C/2.5%5C/servlet-api-2.5.jar%3Cjavax.servlet%28ServletResponse.class%E2%98%83ServletResponse%7EgetOutputStream%E2%98%82IllegalStateException>- if the getWriter method has been called on this response" So, Wicket can't render the error page. -- Cristiano On Tue, Feb 10, 2009 at 5:57 AM, Anton Veretennikov < anton.veretenni...@gmail.com> wrote: > Hello, all wicket users! > > I receive HTTP Status 500 error in this situation: > > I have a page with empty html-file and page's onRender() looks like: > > OutputStreamWriter writer = null; > try { > writer = new OutputStreamWriter(getResponse().getOutputStream(), > encoding); > String enc = getRequestCycle().getResponse().getCharacterEncoding(); > writer.append("<!--" + enc + "-->\n"); > writer.append("....."); > } catch (UnsupportedEncodingException ex) { > throw new WicketRuntimeException("Invalid charset: " + > ex.getMessage()); > } catch (IOException ex) { > throw new WicketRuntimeException("IOException: " + ex.getMessage()); > } finally { > if (writer != null) { > try { > writer.close(); > } catch (IOException ex) { > } > } > } > > > The problem is when this first catch is reached (because encoding > desired is sent as a parameter that could be errouneous) and > > new WicketRuntimeException("Invalid charset: " + ex.getMessage()); > > is thrown I see HTTP Status 500 error with this: > > ERROR - WicketFilter - closing the buffer error > java.lang.IllegalStateException: getOutputStream() has already been > called for this response > at > org.apache.catalina.connector.Response.getWriter(Response.java:610) > at > org.apache.catalina.connector.ResponseFacade.getWriter(ResponseFacade.java:198) > at > org.apache.wicket.protocol.http.WebResponse.write(WebResponse.java:365) > at > org.apache.wicket.protocol.http.BufferedWebResponse.close(BufferedWebResponse.java:73) > at > org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:471) > at > org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:288) > > I would like to know is it proper to throw WicketRuntimeException in > such situation. > For example I want to show standart Wicket Error page. > > Thank you very much. > > -- Tony > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > >