tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <ch...@christopherschultz.net>
Subject Re: best practice for temporary file
Date Fri, 20 Jul 2018 14:42:01 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Chris,

On 7/17/18 10:36 AM, Chris Cheshire wrote:
> James, this can be done using something like the following 
> configuration in your META-INF/context.xml (I use tomcat 8.5)
> 
> <Resources> <PreResources
> className="org.apache.catalina.webresources.DirResourceSet" 
> base="${catalina.base}/cdn/ROOT/images" webAppMount="/images" /> 
> </Resources>
> 
> I use this to serve files at /images because they are dynamic
> content and not part of the war itself. Make sure the directory
> specified by "base" has read and write permission by the tomcat
> user at the OS level and then you can serve files with a uri
> starting with /images/.

Just be careful about doing this kind of thing because Tomcat will
cache resources it finds there, or at least the metadata about those
files. So if you get a cache miss on a file that doesn't exist, Tomcat
may "remember" that the resource doesn't exist when you write a file
to that directory and then the cache will be stale.

You must arrange for the first access of the file by the client to
occur after the file has been written to the disk, otherwise you risk
these kinds of problems.

Also, things can get weird when the file is subsequently removed.

Just be careful.

- -chris

> On Tue, Jul 17, 2018 at 10:21 AM James Finnall <James@finnall.net>
> wrote:
>> 
>> Hello all,
>> 
>> What is the best practice under Tomcat to create a data file and
>> then allow the client to download it?
>> 
>> So far all my attempts have failed.  If the Java app can write it
>> then the client can not download, if client can download then the
>> Java app can not write it.
>> 
>> Does Tomcat have a provision to create a directory that be shared
>> by both the app and the client?
>> 
>> 
>> Thank you for your consideration, James
>> 
>> 
>> ---------------------------------------------------------------------
>>
>> 
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>> 
> 
> ---------------------------------------------------------------------
>
> 
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAltR9LgACgkQHPApP6U8
pFg2TRAAng/d0PPz5CWwTEgyGvr39+eJ8kFB62f4301s9hVhNbgVZfx0RYn0BOe4
shTqsJ7SHJnQJKf9dfOuEcxm6waMsm8BNir+CeAuDGDGjqTLHurhBCYn1K18IOt2
vb/AqPC/R6uFahipAZ2Rquzl/ee4b+/1ikJmDFa+0psmS/aSLpwGEFUyT2yjgzQF
mP5jQY47nsCikDpXTPhTTRGI1wLM5WsHvxRBeSDWTutK5MSZcscJStEuU+P//KLz
AJYNrGoGv1wGZuAhOizKeR5BKZRp+63TA5xITGGKWNJWhV/q2J1n0u4QESE/4d84
b7k3PvEpb7JQ9uji/U9Ocpm3a7QgoFrMRStvtFiJ8/bRRtpyvgvMvMPB4YQ/Jk41
wvpL8WR6xsXFB27RZU3iqzOPUjARgSOSJXrpQJGbpYZrg/z0Rc4CbIfPiMDafcdr
FScZi5Zp7hpwK6tIq+Apo1KftiQOaiF6pMIizYChp3e4/uVZDgg2GuHQByxeq1LZ
+JeiuTzYG1VJSum3dEYY80CcKtzKol9J6yEa4/9ItetA2vc76TzF/V/4PYtMVRX8
nUePOeICJaaczNIs+P9CjD1mQfcCwn+ZqsKM7nj2jE+XhLfwEClafkVkYE33nI/q
jdzMWjh6VIUFzy2vUhxzW0QHVjEvQNF+vCMUDskHuUxbddswmHs=
=tF8U
-----END PGP SIGNATURE-----

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


Mime
View raw message