struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <>
Subject Re: Has any one used struts and log4j successfully?
Date Thu, 01 Mar 2001 05:49:23 GMT
Mark Balster wrote:

>             FileInputStream inFile = new
> FileInputStream(getServletContext().getRealPath(messages.getMessage("Log.Pro
> pertiesFile")) );

You should also be aware that this will only work if your servlet container
unpacks your web application into an open directory structure.  If it runs
directly out of the WAR file (or out of blob objects in a database, for
example), the getRealPath() call will return null.

In such a case, you might wish to use the temporary working directory provided
to you by the servlet container as a context attribute:

    File workDir = (File)
    File logFile =
      new File(workDir, messages.getMessage("Log.Properties.File"));
    String logPathname = logFile.getAbsolutePath();

Of course, there are no guarantees that the temporary work directory will
survive the shutdown of your servlet container -- check the container docs for


View raw message