From: Keats <ke...@xa...> - 2004-03-01 16:28:30
|
Tim, Without the StackTrace I have to guess ... I'm guessing the exception is happening when you call getWriter() on the response. The JavaDocs for this method say: IllegalStateException if the getOutputStream method has already been called for this response object So I'm guessing that you've already called getOutputStream somewhere. I'd suggest just sticking with the output stream. Eg, change: String o = template.evaluateAsString(wc); wc.getResponse().getWriter().write(o); to template.write(wc.Response().getOutputStream(), wc); Hope this helps. Keats ----- Original Message ----- From: "Tim Pizey" <ti...@pa...> To: <web...@li...> Sent: Friday, February 27, 2004 8:21 PM Subject: Re: [WebMacro-user] Problems upgrading Melati to WebMacro 2.0b1 On Friday 27 February 2004 11:05 pm, Brian Goetz wrote: > >The problem seems to be that org.webmacro.Template no longer > >renders to a FastWriter but to an OutputStream, which breaks > >my rendering to a string buffer, as a StringWriter does not have > >an OutputStream ???? > > Template can also render directly to a String. I am getting IllegalStateException from the following public class WebmacroTemplate implements Template { private org.webmacro.Template template; public WebmacroTemplate(org.webmacro.Template t) { template = t; } /** * @param out A {@link MelatiWebmacroWriter}. */ public void write(MelatiWriter out, TemplateContext templateContext, TemplateEngine engine) throws TemplateEngineException { try { WebContext wc = (WebContext)templateContext.getContext(); if (out instanceof MelatiStringWriter) { String o = template.evaluateAsString(wc); wc.getResponse().getWriter().write(o); } else { OutputStream o = ((MelatiWebmacroWriter)out).getOutputStream(); template.write(o, wc); } } catch (ContextException e) { throw new TemplateEngineException(e); } catch (IOException e) { throw new TemplateEngineException(e); } } } going to bed, my eyes hurt Tim Pizey ------------------------------------------------------- SF.Net is sponsored by: Speed Start Your Linux Apps Now. Build and deploy apps & Web services for Linux with a free DVD software kit from IBM. Click Now! http://ads.osdn.com/?ad_id56&alloc_id438&op=ick _______________________________________________ Webmacro-user mailing list Web...@li... https://lists.sourceforge.net/lists/listinfo/webmacro-user |