V
Vlamos
Hello,
I have a servlet that transforms a XML and XSL file into a HTML page.
So the servlet uses 2 files on the server. Now I want to use an XML
file that is generated by a php script on a different server.
This is a part of the code :
public void transformToHtml(String xmlFileName, HttpServletResponse res) {
    Â
try {
            //create xmlSource
         Source xmlSource = new StreamSource(xmlFileName);
      PrintWriter out = res.getWriter();
      //do the actual transformation on the XML source and
      //send output through ServletOutputStream
      transformer.setOutputProperty(OutputKeys.METHOD, "xml");
      transformer.setOutputProperty(OutputKeys.INDENT, "yes");
      transformer.transform(xmlSource, new StreamResult(out));
     Â
  } catch (TransformerConfigurationException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  } catch (TransformerException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  } catch (IOException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  }
    Â
}
So the transformToHTML takes a xmlfile and the servlet response to write
to...  But how can I use an URL as file? Do I have to retrieve the file,
store it as a XML file and transform it?
Thanks !
Tom
I have a servlet that transforms a XML and XSL file into a HTML page.
So the servlet uses 2 files on the server. Now I want to use an XML
file that is generated by a php script on a different server.
This is a part of the code :
public void transformToHtml(String xmlFileName, HttpServletResponse res) {
    Â
try {
            //create xmlSource
         Source xmlSource = new StreamSource(xmlFileName);
      PrintWriter out = res.getWriter();
      //do the actual transformation on the XML source and
      //send output through ServletOutputStream
      transformer.setOutputProperty(OutputKeys.METHOD, "xml");
      transformer.setOutputProperty(OutputKeys.INDENT, "yes");
      transformer.transform(xmlSource, new StreamResult(out));
     Â
  } catch (TransformerConfigurationException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  } catch (TransformerException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  } catch (IOException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  }
    Â
}
So the transformToHTML takes a xmlfile and the servlet response to write
to...  But how can I use an URL as file? Do I have to retrieve the file,
store it as a XML file and transform it?
Thanks !
Tom