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
<%@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);
}
%>
The exception is : java.lang.IllegalStateException: getOutputStream() has already been called for this response
So how can i get rid of that. Thanks