There are a couple ways to proceed with this, but both are related.


1. Add an <env-entry> to your web.xml with a default location for file storage. You then override this in the Tomcat configuration via the <Environment> element. For instance...

web.xml...

    <env-entry>
        <description>File storage for this webapp</description>
        <env-entry-name>fileStore</env-entry-name>
        
<env-entry-value>/change/this/path/in/proprietary/server/deployment/config</env-entry-value>
        <env-entry-type>java.lang.String</env-entry-type>
    </env-entry>

server.xml or context configuration file...

 <Context ...>
    ...
    <Environment name="fileStore" type="java.lang.String"
                value="C:\my\filestore\path" override="true"/>
    ...
  </Context>

and access it from your application like this:

  InitialContext ic = new InitialContext();
  String appFileStore = (String) ic.lookup("java:comp/env/fileStore");


2. Add a <context-param> to your web.xml with a default location for file storage. You then override this in the Tomcat configuration via the <Parameter> element. For instance...


web.xml...

    <context-param>
        <param-name>fileStore</param-name>
        
<param-value>/change/this/path/in/proprietary/server/deployment/config</param-value>
    </context-param>

server.xml or context configuration file...

 <Context ...>
    ...
    <Parameter name="fileStore"
                value="C:\my\filestore\path" override="true"/>
    ...
  </Context>

and access it from your application like this:

String appFileStore = getServletContext().getInitParameter("fileStore");


In your deployment instructions, you would specify that the deployer modify the path to something valid on the local machine. This makes it so that you can send your app as a .war file and no one has to modify anything inside that .war file. Everything is set to go on your end and you simply require a small step to be completed before deployment.


Jake


At 03:58 PM 3/29/2003 +0100, you wrote:
Hi Kaarle,

Thx for the input.
Unfortunately the development system is Windows and production system is
Unix, so absolute paths will never be the same.

Do you have any idea for how to manage properties files which will be
different for windows than unix?
Should I create a separate web_local and web_remote directory and make a
simple ant copy task to distinguish production/development?
Or is there a more elegant approach to this?

thx alot
Johannes




Kaarle Kaila <[EMAIL PROTECTED]> 29.03.2003 15:41 Please respond to "Tomcat Users List" <[EMAIL PROTECTED]>


To "Tomcat Users List" <[EMAIL PROTECTED]> cc

Subject
Re: Where to store files in a portable app?






At 15:35 29.3.2003 +0100, you wrote: >HI there, > >In my app I need to store files after a transaction is complete. >I want to keep my application portable, so where should I store such files >to??

I would put the directory address for the files in a properties file
(ResourceBundle)
Then you can really put them anywhere you like.

regards
Kaarle


>Should I use a /output/.. directory in the root area or where else could >be a smart location? > >Any ideas on this topic?? > >thx alot >Johannes

---------------------------------------------
Kaarle Kaila
http://www.iki.fi/kaila
mailto:[EMAIL PROTECTED]
tel: +358 50 3725844


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

Reply via email to