The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
October 2001

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

Java code in jsp using javax.xml.

Posted by Mustapha Fares on November 09, 2001 at 5:32 AM

i have a problem when i run the following code :
//Start Code
<%@ page language="java" import="javax.xml.transform.TransformerFactory, javax.xml.transform.Transformer,javax.xml.transform.stream.StreamSource,javax.xml.transform.stream.StreamResult,javax.xml.transform.dom.*,javax.xml.parsers.*,org.w3c.dom.*, java.io.*" contentType="text/html; charset=UTF-8" %>
<%
Reader x = new StringReader(anyXMLString);
Writer y = new StringWriter(10000);
TransformerFactory tFactory=TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer(new StreamSource("anyXMLFile.xsl"));
transformer.transform(new StreamSource(x), new StreamResult(y));
%>
<%= y.toString() %>
// END Code

Replace anyXMLString with any xml String
Replace anyXMLFile with any xsl File

y.toString() do not return any output.

I tried the same code in a class and it work but not in .jsp file

thank you

Mustapha






Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us