tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bill Barker" <wbar...@wilshire.com>
Subject Re: WAR format question
Date Tue, 04 Feb 2003 08:34:12 GMT
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" <jcarlson@jnous.com> wrote in message
news:3E3EE25C.40806@jnous.com...
> 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: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message