Re: load files on tomcat

2006-10-18 Thread Michael Courcy
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

Re: load files on tomcat

2006-10-18 Thread David Smith
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

Re: load files on tomcat

2006-10-18 Thread harl3kin
;> >>> >> 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

Re: load files on tomcat

2006-10-15 Thread David Smith
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

Re: load files on tomcat

2006-10-13 Thread Mark Miller
, 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

Re: load files on tomcat

2006-10-13 Thread David Smith
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

Re: load files on tomcat

2006-10-13 Thread José Roberto Motta Garcia
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

load files on tomcat

2006-10-13 Thread harl3kin
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