While I am researching the solution here is more info for better information:
Servlet:
package servlets;
import dombuilders.*;//My package
import xmlxslttransformers.*;//My package
import java.io.*;
import java.net.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HtmlViewServlet extends HttpServlet {
ServletContext sc;
String sXmlFilePath = "xml/article.xml";//hard coded for dev purposes
String sXSLFilePath = "xsl/article.xsl";//hard coded for dev purposes
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
//this is the call to the class that performs the transforms.
new TXMLTransformer(sXmlFilePath, sXSLFilePath);
}
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
}
Transformer class with exceptions and imports left out:
package xmlxslttransformers;
public class TXMLTransformer
{
public TXMLTransformer(String xmlFilePath, String xslFilePath){//explicit contructor
ToHtml(xmlFilePath, xslFilePath)
}
public void ToHtml(String xmlFilePath, String xslFilePath){
File stylesheet = new File(xslFilePath);
File datafile = new File(xmlFilePath);
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
TransformerFactory tFactory = TransformerFactory.newInstance();
try{
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(datafile);//'document' represents our DOM in memory which was created from the xml file
StreamSource stylesource = new StreamSource(stylesheet);
Transformer transformer = tFactory.newTransformer(stylesource);
DOMSource source = new DOMSource(document);
StreamResult result = new StreamResult(System.out);
transformer.transform(source, result);
My goal is to get the html output into the servlet and then displayed in the broswer when this servlet is called. In the stand alone app using System.out for result, the html prints out. My question is how do i get the html to print out to the browser. Thanks,
[ January 23, 2006: Message edited by: Stu Higgs ]