I'm using the following code to read a file in META-INF
URL prop = application.getResource("/META-INF/config.properties");
if (prop == null) {
throw new Exception("Cannot locate the configuration file.");
}
session = _session;
propertiesurl = prop;
InputStream in = prop.openStream();
Properties p = new Properties();
p.load(in);
in.close();
This works in both tomcat and jboss.
Then later one, I want to be able to save the changes. Using code
similar to this
FileOutputStream fos = new FileOutputStream(new File(propertiesurl.toString()));
String msg="Edited at " + System.currentTimeMillis() + " by "
+ request.getRemoteUser();
p.store(fos, msg);
fos.close();
The propertiesurl.toString() method in tomcat returns a JNDI URL,
which cannot be used using the file io api's. In Jboss, this code
works just fine. Application.getResource returns a file:/// url.
So the question is, how can get the same type of setup in Tomcat?
(write to a file in META-INF)