Re: SERVLET : transform XSL+XML ->OUTPUT = blank page
Doesn't getServletContext().getResourceAsStream ("/WEB-INF/classes/login.xml")); have to be getServletContext().getResourceAsStream("/login.xml")); ? - fs |+---> || Pedro Salazar| || | || | || 06/27/2001 10:34 AM | || Please respond to| || tomcat-user | || | |+---> >| | | | To: [EMAIL PROTECTED] | | cc: (bcc: Fernando Salazar/CAM/Lotus) | | Subject: SERVLET : transform XSL+XML ->OUTPUT = blank page | >| 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"); ...
Re: SERVLET : transform XSL+XML ->OUTPUT = blank page
Pedro Salazar wrote: > 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... > I just solve my problem... but before,... [remember] -I haven't no exception in servlet, just a blank page; -my isolated class test worked just fine with the output expected; [my test] -I put my classpath in my isolated class test exactly with the same classpath as tomcat gets when it starts. [result] - An exception occurred: javax.xml.transform.TransformerConfigurationException: Namespace not supported by SAXParser [why...] Why there is no exception in servlet? I just don't know!?! [What I did...] -I edited my "tomcat.sh" script I just after the definition of CLASSPATH, I redefined the CLASSPATH with xerces.jar (the one that came with xalan) in the beginning and the rest after. [what happened...] -Works ok... [conclusions...] -Why there is no exception in servlet since in any exception I write in log and I write to outputstream of response??? -What is the conflict jar of tomcat with xerces.jar, since when I use xerces it works just fine. thanks, Pedro Salazar