Or if your resource are strored in a package try
theObjectOf MyPackage.getClass().getResourceAsStream("image.gif");
Often used when sevlet inside a jar should serve content in the jar as well.
David Smith a écrit :
If you are trying to read from a servlet, it's:
getServletContext().getResourc
If you are trying to read from a servlet, it's:
getServletContext().getResource( "/WEB-INF/graphics/test.gif" )
getServletContext().getResourceAsStream( "/WEB-INF/graphics/test.gif" ) ;
The first one retrieves a URL object that can be used to open an input
stream. The second returns an input s
;>
>>>
>> 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@tomcat.apache.org
> To u
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 r
,
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
The problem is the "current directory" is the startup directory for
tomcat. In a webapp that might be running on several different
installations, the current working directory is a moving target.
Given this is always used from an exploded webapp and not a .war file,
you could use ServletConte
Are u trying to access this image from a class or from a JSP? Please
correct me people, but the root path to JSP files is
/webapps/.
JR
harl3kin wrote:
> hello alltogether,
>
> i have a problem with accessing files deployed on tomcat. I want to access
> an image which is stored in a "graphics" fo
appreciate your time,
Thorsten
--
View this message in context:
http://www.nabble.com/load-files-on-tomcat-tf2438873.html#a6800963
Sent from the Tomcat - User mailing list archive at Nabble.com.
-
To start a new topic, e-mail: u