I haven't tried this for your particular case, Mike, but the default root for
all web applications under a JRun server is the server's root directory.  So if
you just specify a file name, JRun will look in JRUN_HOME/servers/servername/
for that file.  I have no idea if this is kosher according to any spec., but it
might work.  Obviously this blows portability for resources you'd want to bundle
into a war file, but that's another problem.  Maybe you or one of the other
engineers on this list has some comments on how this ought to work according to
the spec?

Scott Stirling

> -----Original Message-----
> From: Mike Hogarth [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, August 06, 2000 5:22 AM
> To: [EMAIL PROTECTED]
> Subject: getResourceAsStream()
>
>
> Anyone know the path + actual directory that is required in order to
> load a .war resource using getResourceAsStream()?
>
> This works with JRun 3.0 (this is the pre-war way of doing things):
> InputStream is_xsl =
> this.getClass().getClassLoader().getResourceAsStream("edu/ucd/guidelin
> es/Headache.xsl");
>
> The new API allows the following, but I keep getting a NullPointerException:
> ServletContext sc = this.getServletConfig().getServletContext();
> InputStream is_xml = sc.getResourceAsStream("/guidelines/Headache.xml");
>
> I know the ServletContext is being obtained correctly as other
> methods in ServletContext work fine.  I figure it has to be the path
> format for the resource.
>
> I have the document within the following directory structure:
>
> /WEB-INF
>       /guidelines
>               Headache.xml
>
> Wonder if the path name I'm using with getResourceAsStream() is not
> in the correct format. Can't seem to find a mention of the right
> format anywhere.
>  I assume that others have successfully used this method with JR3.
>
> Thanks in advance,
> Mike H

------------------------------------------------------------------------------
Archives: http://www.egroups.com/group/jrun-interest/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/jrun_talk
or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the 
body.

Reply via email to