You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by ramzi khlil <ra...@gmail.com> on 2009/09/02 18:46:15 UTC

Share file between 2 apps

Hi All,

I need to share a file between two applications, A and B.
A: I put my web site under Root folder and it is using test.xml file.
B: The second application which generate the xml file is host under webapps
application.
My question is how to allow to application B to update test.xml ?

Regards

Re: Share file between 2 apps

Posted by ramzi khlil <ra...@gmail.com>.
Hi,

There is no way to reload it outside the ClassLoader.

Ramzi

On Wed, Sep 2, 2009 at 2:02 PM, Tim Funk <fu...@apache.org> wrote:

> If the file is loaded via a ClassLoader - then the JVM will cache it and
> you'll need to reload the webppa or restart tomcat.
>
> -Tim
>
> ramzi khlil wrote:
>
>> Hi,
>>
>> Thank you for your response. It's working for me.
>> I have a problem with caching. The server doesn't update the file in temp
>> directory. I set cachingAllowed to false, but it doesn't work for me.
>> Do you have any idea ?
>>
>> Regards
>>
>>
>> On Wed, Sep 2, 2009 at 1:01 PM, Tim Funk <fu...@apache.org> wrote:
>>
>> There are too many unknown constraints to answer - but I'll try.
>>>
>>> In app B - use an init parameter which is a filename where test.xml is
>>> located.
>>>   <context-param>
>>>       <param-name>myfile</param-name>
>>>       <param-value>/usr/local/more/cowbell/test.xml</param-value>
>>>   </context-param>
>>>
>>> Then when app b needs to write the file;
>>> File f = new File(servletContext.getInitParameter("myfile"));
>>> FileWriter fw = new FileWriter(f);
>>> fw.write(stuff);
>>> ...
>>>
>>> If you need to read the file from app B, use a file reader. This is an
>>> easy
>>> way to keep the apps decoupled
>>>
>>>
>  ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: Share file between 2 apps

Posted by Tim Funk <fu...@apache.org>.
If the file is loaded via a ClassLoader - then the JVM will cache it and 
you'll need to reload the webppa or restart tomcat.

-Tim

ramzi khlil wrote:
> Hi,
> 
> Thank you for your response. It's working for me.
> I have a problem with caching. The server doesn't update the file in temp
> directory. I set cachingAllowed to false, but it doesn't work for me.
> Do you have any idea ?
> 
> Regards
> 
> 
> On Wed, Sep 2, 2009 at 1:01 PM, Tim Funk <fu...@apache.org> wrote:
> 
>> There are too many unknown constraints to answer - but I'll try.
>>
>> In app B - use an init parameter which is a filename where test.xml is
>> located.
>>    <context-param>
>>        <param-name>myfile</param-name>
>>        <param-value>/usr/local/more/cowbell/test.xml</param-value>
>>    </context-param>
>>
>> Then when app b needs to write the file;
>> File f = new File(servletContext.getInitParameter("myfile"));
>> FileWriter fw = new FileWriter(f);
>> fw.write(stuff);
>> ...
>>
>> If you need to read the file from app B, use a file reader. This is an easy
>> way to keep the apps decoupled
>>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Share file between 2 apps

Posted by ramzi khlil <ra...@gmail.com>.
Hi,

Thank you for your response. It's working for me.
I have a problem with caching. The server doesn't update the file in temp
directory. I set cachingAllowed to false, but it doesn't work for me.
Do you have any idea ?

Regards


On Wed, Sep 2, 2009 at 1:01 PM, Tim Funk <fu...@apache.org> wrote:

> There are too many unknown constraints to answer - but I'll try.
>
> In app B - use an init parameter which is a filename where test.xml is
> located.
>    <context-param>
>        <param-name>myfile</param-name>
>        <param-value>/usr/local/more/cowbell/test.xml</param-value>
>    </context-param>
>
> Then when app b needs to write the file;
> File f = new File(servletContext.getInitParameter("myfile"));
> FileWriter fw = new FileWriter(f);
> fw.write(stuff);
> ...
>
> If you need to read the file from app B, use a file reader. This is an easy
> way to keep the apps decoupled
>
> -Tim
>
>
> ramzi khlil wrote:
>
>> Hi All,
>>
>> I need to share a file between two applications, A and B.
>> A: I put my web site under Root folder and it is using test.xml file.
>> B: The second application which generate the xml file is host under
>> webapps
>> application.
>> My question is how to allow to application B to update test.xml ?
>>
>> Regards
>>
>>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: Share file between 2 apps

Posted by Tim Funk <fu...@apache.org>.
There are too many unknown constraints to answer - but I'll try.

In app B - use an init parameter which is a filename where test.xml is 
located.
     <context-param>
         <param-name>myfile</param-name>
         <param-value>/usr/local/more/cowbell/test.xml</param-value>
     </context-param>

Then when app b needs to write the file;
File f = new File(servletContext.getInitParameter("myfile"));
FileWriter fw = new FileWriter(f);
fw.write(stuff);
...

If you need to read the file from app B, use a file reader. This is an 
easy way to keep the apps decoupled

-Tim

ramzi khlil wrote:
> Hi All,
> 
> I need to share a file between two applications, A and B.
> A: I put my web site under Root folder and it is using test.xml file.
> B: The second application which generate the xml file is host under webapps
> application.
> My question is how to allow to application B to update test.xml ?
> 
> Regards
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org