Hello,
we have an own settings file and we want to read it, what is the right/best way to do this? We have tried simply with java.io.File(findCISDirectory()+“name.ext”) but this seems to be wrong, isn’t it?
Thanks in advance
Hello,
we have an own settings file and we want to read it, what is the right/best way to do this? We have tried simply with java.io.File(findCISDirectory()+“name.ext”) but this seems to be wrong, isn’t it?
Thanks in advance
Hi,
there are two ways:
(1) through the file system. Via the “Params.getApplicationDircectoryName()” you can get the directory path into the webapplication and then read via file IO. BUT: this is not recommended! It is only supported with servlet engines supporting file access - e.g. JBoss will have problems.
(2) through the servlet context. The servlet context provides the possibility to access all files of the web application. We hava a wrapper class for accessing the servlet context which is WebResourceReader. You pass as parameter the path within your web applciation (e.g. “WEB-INF/web.xml”) and receive back the content.
For “serious” J2EE implementation only (2) is an option! (1) must only be used in case you are sure forever to live in a Tomcat environment. Only (2) still works with cluster scenarios!
Hope this helps…
Bj
Thanks! Second way seems to be exactly what we’ve bin looking for!