Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • Use a ResourceBundle. See the Java docs for the specifics of how the ResourceBundle class works. Using this method, the properties file must go into the WEB-INF/classes directory or in a jar file contained in the WEB-INF/lib directory.
  • Another way is to use the method getResourceAsStream() from the ServletContext class. This allows you update the file without having to reload the webapp as required by the first method. Here is an example code snippet, without any error trapping:
    No Format
        // Assuming you are in a Servlet extending HttpServlet
        // This will look for a file called "/more/cowbell.properties" relative
        // to your servlet Root Context
        InputStream is = getServletContext().getResourceAsStream("/more/cowbell.properties");
        Properties  p  = new Properties();
        p.load(is);
        is.close();  


Can I set Java system properties differently for each webapp?

No. If you can edit Tomcat's startup scripts, you can add "-D" options to Java. But there is no way to add such properties in web.xml or the webapp's context.

How do I use log4j for all Tomcat log output?

...

Wiki Markup
John Turner has an excellent page about \[http://johnturner.com/howto/apache-tomcat-howto.html Using Apache HTTP with Apache Tomcat\].  Several different connectors have been built, and some connector projects have been abandoned (so beware of old documentation).

How do I configure Tomcat to work with IIS and NTLM?

...