Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_jsp thread: RE: XML, XSL and jsp question


Message #1 by Grant Priestley <gpriestley@l...> on Fri, 1 Mar 2002 11:39:26 +1100
have a look at pageContext.getRealPath() which will resolve any virtual or
relative file path under you web application directory. So, if you pass
phoenix/xml/test.xml to it, it will resolve it to

d:/tomcat/webapps/ROOT/phoenix/xml/test.xml"

on your system. Very useful should you then decide to move the webapp out of
the tomcat installation or whatever

chanoch


-----Original Message-----
From: Grant Priestley [mailto:gpriestley@l...]
Sent: 01 March 2002 00:39
To: Pro_JavaServer_Pages
Subject: [pro_jsp] RE: XML, XSL and jsp question


hi guys...  

i have a question regarding an example of importing XML and XSL into a jsp
page (chapter 12) 
 first of all... here's the code:
<%
  StreamSource xml =new StreamSource(new
File("d:/tomcat/webapps/ROOT/phoenix/xml/test.xml"));
  StreamSource xsl =new StreamSource(new
File("d:/tomcat/webapps/ROOT/phoenix/xml/test.xsl"));

  StreamResult result = new StreamResult(out);

  TransformerFactory tFactory = TransformerFactory.newInstance();
  Transformer transformer = tFactory.newTransformer(xsl);

  transformer.transform(xml, result);
%> 

and now the question.... how do i include the xml & xsl files in a relative
manner... that is
"/phoenix/xml/test.xml" instead of
"d:/tomcat/webapps/ROOT/phoenix/xml/test.xml"

i'm using tomcat 4.02 and the new JDK.1.4


thanx in advanced

g!

  Return to Index