Reading xsl from jsp

pandegkyen

New Member
I want to open the stream from xml file, then use xsl tranformation in a jsp file. Everything seems correct, but I dont know why there is an exception when I getOutput from response.This is my code \[code\]<%@page import="javax.xml.transform.*" %><%@page import="javax.xml.transform.stream.*" %><%@page import="java.io.*" %><%StreamSource xmlSource = new StreamSource( new File(application.getRealPath("foo/cd.xml")));StreamSource xsltSource = new StreamSource( new File(application.getRealPath("foo/cd.xsl")));StreamResult fileResult = new StreamResult(response.getOutputStream());try { // Load a Transformer object and perform the transformation TransformerFactory tfFactory = TransformerFactory.newInstance(); Transformer tf = tfFactory.newTransformer(xsltSource); tf.transform(xmlSource, fileResult);} catch(TransformerException e) { throw new ServletException("Transforming XML failed.", e);}%>\[/code\]The exception is : java.lang.IllegalStateException: getOutputStream() has already been called for this responseSo how can i get rid of that. Thanks
 
Back
Top