Read-only files can be placed anywhere you want.  For files that you need to
write to, use the 'javax.servlet.context.tmpdir' attribute of the
ServletContext (since you can't write to a WAR file :).  Assuming that your
servlet extends GenericServlet (this includes the cases of HttpServlet, and
Tomcat's default JSP page Servlet), then something like:

  String tmpDir =
getServletContext().getAttribute("javax.servlet.context.tmpdir");
  File outFile = new File(tmpDir, "myFile.ext");
  OutputStream outF = new FileOutputStream(outFile);
  // write something here
  outF.close();

"Jim Carlson" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Hello,
>    I have a question about the WAR directory structure.  Namely, where
> is the appropriate place to put configuration files, log files, and
> other files that need to be read/written-to by my application?  Clearly
> putting them in the webroot isn't right.  Can my application access
> arbitrary files under WEB-INF?  How?  I know that conf files can be put
> in the classpath (e.g. WEB-INF/classes), but this seems like the wrong
> solution for files that will change after deployment.
>    In the past, I've used the technique of creating my own application
> root, which contained a webroot/ directory in the WAR format, and
> pointed the servlet container at that.  I used servlet parameters in the
> web.xml file to specify the location of the application root to my
> servlets, so that they could access my conf/log files.  This works fine,
> but forces me to 'embrace and extend' the orginal WAR concept.
>    Any suggestions?
>
> Thanks,
>
> Jim Carlson




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to