dah pra fazer isso com o spring… dae ele injeta a taxa pra vc q ficaria no application context (q eh um xml)…
eu fiz um esqueminha na mao tmb prum relatorio acessando um .properties saca só:
private static final Properties propRelatorio;
private static final String diretorio;
static {
propRelatorio = new Properties();
//essa linha tah pegando o endereco do diretorio no web.xml
diretorio = BaseBackingBean.getContextParam("DIRETORIO_RELATORIO");
FileInputStream arquivoConfig = null;
try {
arquivoConfig =
new FileInputStream(diretorio + "relatorio.properties");
propRelatorio.load(arquivoConfig);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (arquivoConfig != null)
try {
arquivoConfig.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
public static String getPropriedade(String prop) {
return propRelatorio.getProperty(prop);
}
dae no web.xml
<context-param>
<param-name>DIRETORIO_RELATORIO</param-name>
<param-value>/home/projetos/rodoaereo/relatorio/</param-value>
</context-param>
dae depois uso o conteudo do properties assim:
getPropriedade("chave");