Hi! I want to load an XML-file from a wicket page concerning the html page parameters with javascript. The javascript part (load and parse xml) works fine and also the generated xml file is okay.
I just always get an java.lang.IllegalStateException: getOutputStream() has already been called for this response at org.apache.catalina.connector.Response.getWriter(Response.java:599) at org.apache.catalina.connector.ResponseFacade.getWriter(ResponseFacade.java:195) at wicket.protocol.http.WebResponse.write(WebResponse.java:315) at wicket.protocol.http.BufferedWebResponse.close(BufferedWebResponse.java:75) at wicket.protocol.http.WicketServlet.doGet(WicketServlet.java:229) [...] I did some research on this problem and found some workarounds for jsp. I also tried different combinations of Streams and Writers. Alsways that exception. The code: private void parametersToResponse(Map<String, String> params, Response res) throws IOException { res.setContentType("text/xml"); logger.info("map: " + params); // test for illegal keys if ( containsIllegalKeys(params) || params.isEmpty() ) { logger.warn(howtoString); res.write(howtoString); //works! } else { // get news from database Collection<News> news = getNewsFromDB(params); // create xml document from news Document doc = createXML(news); // write xml file to stream XMLOutputter xmlout = new XMLOutputter(); // res.write( xmlout.outputString( doc ) ); //does not work, res writes xml to beginning of html page xmlout.output(doc, res.getOutputStream() ); //somehow dublicate call of getOutputStream !!! } } Another solution would be, not to use XMLOutputter, just response.write("..."), but I don't get a correct XML file but just my xml put before the html: <?xml version="1.0" encoding="UTF-8"?> <newsList [...] <html> <head>[...] Anybody an idea how to solve the former or the latter? Regards, Daniel ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user