we do something similar but we use the WEB-INF directory as the starting point and all works fine lets say we are looking for "XML/extraction-map-classday.xml"
the following code achieves this ... public final class HomePageAction extends Action ... ... String xmlURI = this.getServlet().getServletContext().getRealPath("/WEB-INF/XML/extraction-m ap-classday.xml"); Therefore the "RealPath" to extraction-map-classday.xml = the value in xmlURI if you had "stylesheets\mystylesheet.xsl" under the WEB-INF directory maybe you could follow or approach i know it works for us but maybe we just got lucky !!! HTH Mike ----- Original Message ----- From: "Mazza, Glen R., ,CPMS" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, July 07, 2003 11:38 AM Subject: resolving relative paths to servet webapp/myapp directory > Hello, > > I'm doing an XML->PDF XSLT transformation using a XSL stylesheet. > > Programmatically, within my Action class, I refer to the stylesheet needed > by using a relative path, with the goal of it being relative to my appname > directory off of the servlet "webapps" directory: > > TransformerFactory tFactory = TransformerFactory.newInstance(); > Transformer transformer = tFactory.newTransformer(new > StreamSource("stylesheets\\mystylesheet.xsl")); > .. > > Problem is, Struts appears to be resolving relative paths from my project > working directory, *not* relative to the "appname" from the webapps > directory in Tomcat. > > To confirm this, removing the xsl stylesheet from my working directory > returned this error when I ran the app in Tomcat: > > java.io.FileNotFoundException: > D:\myworkingdir\myapp\stylesheets\mystylesheet.xsl > > and not this error: > > java.io.FileNotFoundException: > D:\tomcat4.1\webapps\myapp\stylesheets\mystylesheet.xsl > > How do I specify filenames in Struts so they will be resolved relative to > the webapps\myapp directory (whatever I name "myapp" to be), and not my > (deleteable) working directory? > > Thanks, > Glen > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]