load files on tomcat
- From: David Smith <dns4 (at) cornell.edu>
- Date: Sun, 15 Oct 2006 08:59:32 -0400
This is per the spec which explicitly states that the method
getRealPath() will return null if the webapp is executed from an
unexpanded .war file. I believe it's even in the docs for the servlet
api. If however your effort is in just reading the resource, there are
other methods which work regardless of being in a .war file or not --
getResource( path ) and getResourceAsStream( path ).
--David
Mark Miller wrote:
,
you could use ServletContext.getRealPath( ). That will return the
absolute path to the file, but only if the webapp isn't packed up as
.war.
--David
Why is this the case? Doesn't Tomcat extract to war to a webapp/warname
folder when it first accesses it?
- Mark
---------------------------------------------------------------------
To start a new topic, e-mail: users (at) tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe (at) tomcat.apache.org
For additional commands, e-mail: users-help (at) tomcat.apache.org