tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From harl3kin <>
Subject Re: load files on tomcat
Date Wed, 18 Oct 2006 14:27:36 GMT

Hey again,

thanks for your replies. I just want to read the resource file and I tried
the getResource() method, it can't find the resource though. When I get the
absolute path of the context, I receive the file structure where the tomcat
is installed. But does tomcat internally have the same file structure? (i.e.
local tomcat installed on C:\progs\tomcat - ist it correct that tomcat
internally tries to retrieve the wanted file from C:\progs\tomcat\... ?)
I really tried a lot. I thought the problems arise because I have a
windows-tomcat the file structure uses the wrong slashes (so I tried using
"\\" instead of "/" - did not work). 
So to make it really clear:
1. i have a local tomcat installed on windows
2. i have an image deployed on that tomcat on

how can a deployed class on the server correctly read the image that resides
on the same server?

thanks again for your help and patience,

David Smith-2 wrote:
> 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:
> To unsubscribe, e-mail:
> For additional commands, e-mail:

View this message in context:
Sent from the Tomcat - User mailing list archive at

To start a new topic, e-mail:
To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message