Greetings,
I made a servlet where I try to produce a result to output stream of the
response object that came from a transformation of XML + XSL. But, I
just get a blank page in output...!?
I put the same piece of code that exists in doGet() of my servlet in a
isolated test class [but redirecting the output to a file]. I ran it and
it works ok... Why my servlet doesn't give nothing to my client??
I put my code below. My servlet runs in the root "/" of my context.
In my servlet, if I put a println of a string, i will saw the string,
but just the string...
thanks,
Pedro Salazar
---------------
SAMPLE ISOLATED
---------------
...
Source xmlSource = null;
Source xslSource = null;
xmlSource = new javax.xml.transform.stream.StreamSource("login.xml");
xslSource = new javax.xml.transform.stream.StreamSource("login.xsl");
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer(xslSource);
transformer.transform(xmlSource, new StreamResult(new
java.io.FileOutputStream("login.out")));
...
---------------
SERVLET doGet()
---------------
...
Source xmlSource = null;
Source xslSource = null;
PrintWriter out = null;
xmlSource = new StreamSource (
getServletContext().getResourceAsStream("/WEB-INF/classes/login.xml"));
xslSource = new javax.xml.transform.stream.StreamSource (
getServletContext().getResourceAsStream("/WEB-INF/classes/login.xsl"));
Transformer transformer = tFactory.newTransformer(xslSource);
response.setContentType("text/html; charset=UTF-8");
out = response.getWriter();
transformer.transform(xmlSource, new StreamResult(out));
//out.println("OK");
...