-----------------------------
Please read the FAQ!
<http://java.apache.org/faq/>
-----------------------------

Paul Murphy wrote:

> -----------------------------
> Please read the FAQ!
> <http://java.apache.org/faq/>
> -----------------------------
>
> Thanks John,
>         tried that, java creates the file in your user.dir which isn't much use.
> There are good arguments as to why I shouldn't be able to find out this
> information but I think my need outweighs them.
> I think some of the JServ config info should be at least readable using a
> static method.
> Unless of course there's some sneaky easy way of finding out.
>
> Paul.
>

If you are running Apache JServ in automatic-start mode (the usual way) on a Unix
system, you are going to find that the current working directory is "/" and you
won't be able to write files there anyway. A couple of standard approaches to
dealing with this in a portable manner:

* Define an initialization parameter for your servlet
  that is the pathname to a directory in which the
  servlet can read and write files.  The JSP page
  compiling servlet in JSWDK, for example, uses this
  technique to find the path to a scratch directory where
  it can store the compiled class files for the servlets
  that you generate.

* If all you need to  do is read properties files, by far the
  easiest method is to use the PropertyResourceBundle
  class.  This loads properties files from the class path,
  rather than the file system, so it can even read them out
  of a JAR file that contains your classes.  The "Internationalization"
  section of the JDK documentation bundle has a bunch of
  examples of using this, because it also supports automatic
  localization capabilities, but it is a generally useful technique
  for loading properties without having to tell the server
  explicitly where to find them.

Craig McClanahan




--
--------------------------------------------------------------
Please read the FAQ! <http://java.apache.org/faq/>
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Archives and Other:  <http://java.apache.org/main/mail.html>
Problems?:           [EMAIL PROTECTED]

Reply via email to