static files in WAR?

Hello!I am trying to deploy a WAR file with static files (like text files, etc) inside of the archive. Where exactly should these go to be accessible by the servlet? Is there any other configuration required?Thank you in advance!
[250 byte] By [nawleja] at [2007-11-26 22:29:11]
# 1
You can stick them in WEB-INF/classes and access them via the getResourceAsStream method - check the API http://www.onjava.com/pub/a/onjava/excerpt/jebp_3/index1.html?page=3Good LuckLee
tsitha at 2007-7-10 11:33:00 > top of Java-index,Java Essentials,Java Programming...
# 2
Thank you. That worked perfectly!
nawleja at 2007-7-10 11:33:00 > top of Java-index,Java Essentials,Java Programming...
# 3
You are quite welcome - good luck with it
tsitha at 2007-7-10 11:33:00 > top of Java-index,Java Essentials,Java Programming...
# 4

Hmmm.... I thought that with web apps one should use the ServletContext

methods [url=http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletContext.html#getResource(java.lang.String)]getResource[/url] and [url=http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletContext.html#getResourceAsStream(java.lang.String)]getResourceAsStream[/url]

-- note, not the Class methods with the same name. From the API for these methods:

<quote>

This method has a different purpose than java.lang.Class.getResource, which looks up resources based on a class loader. This method does not use class loaders.

</quote>

DrLaszloJamfa at 2007-7-10 11:33:00 > top of Java-index,Java Essentials,Java Programming...
# 5
I think you can go either way - I prefer to use the classloader but whatever makes you happy:(removed redundant link)Message was edited by: tsith
tsitha at 2007-7-10 11:33:00 > top of Java-index,Java Essentials,Java Programming...
# 6

In regard to the classloader context, I used this for the Servlet component: InputStream is = getServletContext().getResourceAsStream(filename);

Since I am referencing the same config file for the application component that sits on the desktop, i had to use something different since it is not a servlet:

InputStream is = (ClassLoader.getSystemClassLoader()).getResourceAsStream(filename);

Im not sure if the latter example will work with the servlet, but I will check next time I deploy. I'm sure it would.

nawleja at 2007-7-10 11:33:00 > top of Java-index,Java Essentials,Java Programming...