Not to beat people over the head with the servlet spec, this citation
from servlet spec 2.4, SRV.4.5 hints at a possible case where a file
system might not be available:
"In situations where the servlet container cannot determine a valid file
path for
these methods, such as when the Web application is executed from an
archive, on
a remote file system not accessible locally, or in a database, these
methods must
return null."
I remember some discussion a looong time ago referencing a servlet
container inside of Oracle as a use case for getRealPath() returning
null since it wouldn't be backed by a real file system.
--David
Johnny Kewl wrote:
----- Original Message ----- From: "Caldarale, Charles R"
<[EMAIL PROTECTED]>
To: "Tomcat Users List" <users@tomcat.apache.org>
Sent: Thursday, June 05, 2008 1:26 AM
Subject: RE: Relative internal links
From: Johnny Kewl [mailto:[EMAIL PROTECTED]
Subject: Re: Relative internal links
Have a look at this function...
getServletContext().getRealPath("/");
Thats a nice way to find out where you are....
Only if you're running in an environment that supports the call. If
you're on a device without an accessible file system, or if the webapp
is coming out of an unexpanded .war file, you're out of luck.
Depending on getRealPath() indicates you've made a serious design
error somewhere back up the road.
- Chuck
====================
OK interesting... got me as curious as anything ;)
What devices does tomcat run on that doesnt have a file system? Are
you thinking cell?
like "../webapps/MCRCServlets/logs/MCRCServlet.log" in the Java Code.
He's clearly trying to make a private log file folder..
If you dont use getServletContext().getRealPath("/")... what do you
suggest he does?
---------------------------------------------------------------------------
HARBOR : http://www.kewlstuff.co.za/index.htm
The most powerful application server on earth.
The only real POJO Application Server.
See it in Action : http://www.kewlstuff.co.za/cd_tut_swf/whatisejb1.htm
---------------------------------------------------------------------------
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]