RE: resolving relative paths to servet webapp/myapp directory

2003-07-07 Thread Mazza, Glen R., ,CPMS
Thanks to both--I implemented Mike's solution (also placed the stylesheet
more properly under the web-inf directory.)  It worked fine.
(ServletContext.getResourceAsStream() is also a good solution--thanks.)

Glen

-Original Message-
From: Kris Schneider [mailto:[EMAIL PROTECTED]
Sent: Monday, July 07, 2003 2:08 PM
To: Struts Users Mailing List
Subject: Re: resolving relative paths to servet webapp/myapp directory


I tend to use ClassLoader.getResource or ClassLoader.getResourceAsStream to
load
resources. The constraint, obviously, is that the class loader must be able
to
access the resources. Generally, this means placing resources under
WEB-INF/classes or in JAR files in WEB-INF/lib. If you don't care about
depending on the Servlet API, try ServletContext.getResource or
ServletContext.getResourceAsStream. In your particular case, you'd use:

InputStream in =
context.getResourceAsStream("/stylesheets/mystylesheet.xsl");

Quoting Mike Deegan <[EMAIL PROTECTED]>:

> 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

-- 
Kris Schneider <mailto:[EMAIL PROTECTED]>
D.O.Tech   <http://www.dotech.com/>

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



resolving relative paths to servet webapp/myapp directory

2003-07-07 Thread Mazza, Glen R., ,CPMS
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]



placement of XML & XSL files within a Struts webapp

2002-12-12 Thread Mazza, Glen R., ,CPMS
Hello,

Should the XML and XSLT files needed by a web application ordinarily be kept
under web\Web-inf?  (or should they be in web\stylesheets or web\include?)
Assuming two types of files:

1.)  XML lookup data for access by various Action classes and/or JSP pages.
2.)  XSL stylesheets for transforming XML data into HTML and/or PDF.

What's a "good practice" on where they should be stored?

Thanks,
Glen

--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Commons-logging and JDK 1.4 Logger

2002-11-18 Thread Mazza, Glen R., ,CPMS
Hello,

I am thinking of using the JDK 1.4 Logging API directly within some of my
web application classes.  Of course, Struts uses commons-logging for its
"internal" messages, so I still need to configure commons-logging to use the
JDK 1.4 Logging.

I am interested in using the same output logging file for both types of
messages:  those I explicitly call via JDK 1.4 Logging, and those messages
written by Struts via commons-logging.  Can I have them append to the *same*
output log file without concern for them overwriting each other's messages?

Thanks,
Glen

--
To unsubscribe, e-mail:   
For additional commands, e-mail: