What is strange is that if I do getRealPath("/includes/sometext.txt") it is
translating it to "/my_webserver_root/htdocs/includes/sometext.txt" which is
good and that's what getResource does behind the scenes before fetching the
file... right? The file really exist but getResource returns null.
I tried that test with the JRUN web server and the Netscape server but in
both case it's unsuccessful. I tried different web servers since the
getResource call the web server to locate the file. I don't think it's a
problem with the API since it works for you so I guess that JRUN
misimplements it. Does anybody was able to make it work with JRUN?
Pascal
-----Original Message-----
From: Craig R. McClanahan [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, September 07, 1999 7:28 PM
To: [EMAIL PROTECTED]
Subject: Re: ServletContext.getResource() problem
Pascal Houde wrote:
> Hi,
> There's something I don't understand about getResource(String path). What
> the "path" argument is supposed to be? I gave something like
> "/includes/sometext.txt" but getResource always return a null object. Is
it
> an implementation problem from my servlet engine? I am using JRUN2.3.3 for
> NT / JDK1.2 / JSDK2.1.
>
> Thanks in advance
> Pascal
>
According to the "clarifications" to the 2.1 spec that were published in the
JSP 1.0 spec (appendix B), the path for getResource() is interpreted as
being
relative to the "document root" for the servlet context you are running in.
If you're running the JSDK 2.1 servlet engine with an unmodified
configuration, that means a call like this:
URL url = getServletContext().getResource("/abc/def.ghi");
will look for a file at the following path, where $JSDK_HOME is your install
directory:
$JSDK_HOME/webpages/abc/def.ghi
because "webpages" is the document root of the default context (see the
default.cfg configuration file). You will have to check your JRun
documentation to see how the document root is configured for it.
Craig McClanahan
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html