tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jacob Kjome <h...@visi.com>
Subject Re: WAR format question
Date Mon, 03 Feb 2003 23:49:30 GMT

Put stuff that isn't supposed to be accessed via the web under 
WEB-INF.  You can create whatever directory structures you want within that.

In order to obtain access to a file under WEB-INF in a completely portable 
way, use something like...

getServletContext().getResourceAsStream("/WEB-INF/myproperties.xml");

As far as writing stuff to your webapp, there is no guarantee that you have 
access to the file system other than a temporary directory designated for 
your webapp by the servlet container.  You only have access under Tomcat 
because, by default, it exploded .war files to directory structures and 
then serves the directory structure.  However, webapps can be deployed 
entirely from a .war file, in which case you can't use File IO within the 
application structure.  I am acutally looking for a way to be able to write 
directly into an archive such as a .war file.  If you happen on any info on 
that I would love to know about it.

Check out the servlet api.  You may be surprised to find a lot of methods 
like this that make dealing with webapps quite easy.

Jake

At 01:42 PM 2/3/2003 -0800, you wrote:
>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
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message