You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Garret Wilson <ga...@globalmentor.com> on 2019/04/21 14:53:33 UTC

no temp directory creation wanted when embedding Tomcat

As I mentioned in other emails, I am embedding Tomcat 9 (with OpenJDK 11 
on Windows 10) to serve static files from `/foo/bar`. Currently I'm not 
supporting Java webapps. I'm not supporting JSP. I just want to serve 
static files.

 From your help in another thread, I called the magic 
"gets-but-really-creates-a-connection" method and got it working.

But now I realize Tomcat is creating this directory structur inside the 
"base dir" I specified:

tomcat.8080/work/Tomcat/localhost/ROOT

I don't need this directory. I don't want this directory created. How do 
I tell Tomcat not to create no danged directories?

Garret


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


Re: no temp directory creation wanted when embedding Tomcat

Posted by "Mark H. Wood" <mw...@iupui.edu>.
It seems to me that the problem may be, that you are trying to use
Tomcat but cut away most of its raison d'etre.  Asking Google for
"embedded web server java" will give you a lot of other possibilities
to explore, some of them extremely simple.

-- 
Mark H. Wood
Lead Technology Analyst

University Library
Indiana University - Purdue University Indianapolis
755 W. Michigan Street
Indianapolis, IN 46202
317-274-0749
www.ulib.iupui.edu

Re: no temp directory creation wanted when embedding Tomcat

Posted by Garret Wilson <ga...@globalmentor.com>.
On 4/24/2019 12:01 AM, Mark Thomas wrote:
> If you don't want the baggage associated with a Servlet container it
> might be worth looking at what other solutions are available.


Thanks for being forthright here, Mark. (Mark Wood also suggested the 
same thing separately.)

Indeed I have used Jetty in the past for embedding, and in fact that was 
my first thought for this project. But because I use Tomcat for my web 
applications, I thought maybe I had been ignoring Tomcat on this front. 
So I went the extra step of trying Tomcat for embedding, thinking maybe 
it would give me an opportunity to contribute back to this great project 
as well.

I guess I had assumed that Tomcat was "a great server that supports 
servlet technology", when in fact it is "a great servlet container that 
supports serving static files through a default servlet".

I'll think more about this. I have a question about dynamic MIME type 
determination, but I'll ask it separately.

Garret


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


Re: no temp directory creation wanted when embedding Tomcat

Posted by Mark Thomas <ma...@apache.org>.
On 23/04/2019 21:46, Garret Wilson wrote:
> On 4/22/2019 7:58 AM, Mark Thomas wrote:
>> On 21/04/2019 15:53, Garret Wilson wrote:
>>> …
>>> But now I realize Tomcat is creating this directory structur inside the
>>> "base dir" I specified:
>>>
>>> tomcat.8080/work/Tomcat/localhost/ROOT
>>>
>>> I don't need this directory. I don't want this directory created. How do
>>> I tell Tomcat not to create no danged directories?
>> The Servlet specification requires (see section 4.8.1 of the Servlet 4.0
>> spec) that Tomcat provides a private temporary directory for each
>> servlet context (web application).
> 
> 
> I have have several reactions.
> 
> 1. The first is, OK, so the servlet spec requires that the servlet
> container expose a temporary directory. Tomcat can't provide a temporary
> directory to the consumer unless it has a temporary directory, so it's
> reasonable that it creates one.
> 
> 2. But so far nothing has been stored in this directory, so it's
> completely unused. I see also in the `Tomcat` class the comment, "lazy
> init for the temp dir - only when a JSP is compiled or get temp dir is
> called we need to create it. This will avoid the need for the baseDir".
> It sounds like you're lazily creating the JSP temporary directory, so
> why can't we do the same for the context temporary directory, which may
> never be used (and frankly probably won't be used in many applications)?
> But OK, that's a quibble; my other thoughts are more pressing.
> 
> 3. Since the temporary working directory is on a per-context basis, and
> I've only set the "basedir" for the entire `Tomcat` instance, Tomcat
> must be determining a default temporary directory for the context.
> Surely I'm allowed to explicitly specify a temporary directory on a
> per-context basis, but I sure can't find it. The `StandardContext` seems
> to equate the "temporary directory" with the "work directory". Are they
> really the same? If so, I suppose I can just call
> `((StandardContext)context).setWorkDir(String)`?
> 
> 
>> The best you can do is specify an absolute path that already exists for
>> the Context's work directory. It doesn't need to be writeable. If you
>> are using it for multiple web applications you probably don't want it to
>> be writeable.
> 
> 
> Ah, OK—I had read that response earlier, but didn't understand exactly
> what it meant until I investigated and wrote #2 above. So I guess I was
> right: I need to call`((StandardContext)context).setWorkDir(String)`.
> 
> 4. But all this "temporary directory requirement" business is for
> servlet containers. I started out just wanted to embed Tomcat to serve
> static files; I don't (yet? ever?) need a servlet container for this
> particular application. So how can I use Tomcat to serve static files
> without bringing in the requirements of a servlet container?
> 
> Maybe the answer is that Tomcat serves files by using a
> static-file-serving servlet, which in turn requires me to use Tomcat as
> a servlet container even for serving static files, which in turn
> requires me to have a temporary directory I don't want or need.
> 
> I suppose that's just the way it is. This is not so much a complaint as
> a desire to confirm I understand correctly how things stands. (OK, it's
> a teeny-tiny complaint, too.)

Your reasoning above is correct.

If you don't want the baggage associated with a Servlet container it
might be worth looking at what other solutions are available.

Mark

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


Re: no temp directory creation wanted when embedding Tomcat

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Garret,

On 4/23/19 16:46, Garret Wilson wrote:
> On 4/22/2019 7:58 AM, Mark Thomas wrote:
>> On 21/04/2019 15:53, Garret Wilson wrote:
>>> … But now I realize Tomcat is creating this directory structur
>>> inside the "base dir" I specified:
>>> 
>>> tomcat.8080/work/Tomcat/localhost/ROOT
>>> 
>>> I don't need this directory. I don't want this directory
>>> created. How do I tell Tomcat not to create no danged
>>> directories?
>> The Servlet specification requires (see section 4.8.1 of the
>> Servlet 4.0 spec) that Tomcat provides a private temporary
>> directory for each servlet context (web application).
> 
> 
> I have have several reactions.
> 
> 1. The first is, OK, so the servlet spec requires that the servlet 
> container expose a temporary directory. Tomcat can't provide a
> temporary directory to the consumer unless it has a temporary
> directory, so it's reasonable that it creates one.
> 
> 2. But so far nothing has been stored in this directory, so it's 
> completely unused. I see also in the `Tomcat` class the comment,
> "lazy init for the temp dir - only when a JSP is compiled or get
> temp dir is called we need to create it. This will avoid the need
> for the baseDir". It sounds like you're lazily creating the JSP
> temporary directory, so why can't we do the same for the context
> temporary directory, which may never be used (and frankly probably
> won't be used in many applications)? But OK, that's a quibble; my
> other thoughts are more pressing.

Lazy-creation of the directory cannot be accomplished simply. This is
because there is no API call to get the temp directory that will be
used by the context. Or, rather, the API call is too generic. This is
how a web application should use a temporary directory from within
e.g. a servlet:

File tmpDir = (File)
getServletContext().getAttribute(ServletContext.TEMPDIR);
File myFile = new File(tmpDir, "my.file");
// Use myFile...

The only API call to intercept would be ServletContext.getAttribute,
and we'd have to look specifically for the TEMPDIR attribute key.

This can indeed be done, at varying levels of laziness (on the part of
either the Tomcat programmer, or by the code itself to delay as long
as possible).

> 4. But all this "temporary directory requirement" business is for 
> servlet containers. I started out just wanted to embed Tomcat to
> serve static files; I don't (yet? ever?) need a servlet container
> for this particular application. So how can I use Tomcat to serve
> static files without bringing in the requirements of a servlet
> container?

Tomcat is a servlet container. Just because you don't care to use it
as such doesn't mean that Tomcat should be re-architected.

> Maybe the answer is that Tomcat serves files by using a 
> static-file-serving servlet

It does.

> which in turn requires me to use Tomcat as a servlet container even
> for serving static files, which in turn requires me to have a
> temporary directory I don't want or need.

Yes, but I don't believe the DefaultServlet uses the temporary
directory for anything, here. (DefaultServlet does use the temp dir,
but it only uses it for PUT operations.)

> I suppose that's just the way it is. This is not so much a
> complaint as a desire to confirm I understand correctly how things
> stands. (OK, it's a teeny-tiny complaint, too.)

- -chris
-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/

iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAlzAiy8ACgkQHPApP6U8
pFgUvw/+Mo6JNYrffKTVnbphTN7H+nZ6w54s/XwUxduPyLiYR4w6OFKw1ISF3G89
+mFGxUA4P8dHjgptZdLXpWlJ/DxvGKrQ2dBOc9gs12GJKU9LTQyzAVfemRpYpzwC
eNcVtlrp1lRk6BloRLTjkegcB0wfoM+dL+aB7fznq8rF48cSnF+9DXakpltpCO8d
x2W2F8BqHkuzKpQVx8TIoMeN25eZmMSIVHgEQXC/I7r9/Xivi0Tj+iKj/6JUJzMF
e2J6SAFnQnQRJ2f+EMhHG4Mzc+avcZOwdNbEf2hf8vqly67ztqHWGe3DD/9dHix4
gg52Ynf8jlWS45kQGULUHbyLDUUJH4BcRNKVutEToB+dCcPR0Foqhh8HoAEP07yK
cNfuP8FbQf0n2h2lqFXIWBQeiK3Z3iwVhPi8d10gv4MgRyl3u0Bz5Y9N943ChfLn
rAalljDgbRUGAoNZqIV9xDEl+uBORlCd5F3sfzVeZVSoGbRCb+aTPdmiAQ4C2GSN
Z7pQrbIscLocdUW4Xz1/AMecKJbZtM1/ftLzJi6KKuuEwlyv63gnLoj7hRR28S53
XxcRSgiFuqPHl6oGYEBQyHBmMna33C3YNt9XmhUsiZXdqZAkouh+jiLhdiiATk5A
O45IF9wnK7kBb7J0Pd/jNStbapl7wLIzJCghpkhne4XP8Y6N/Ng=
=THOE
-----END PGP SIGNATURE-----

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


Re: no temp directory creation wanted when embedding Tomcat

Posted by Garret Wilson <ga...@globalmentor.com>.
On 4/23/2019 5:46 PM, Garret Wilson wrote:
> 3. Since the temporary working directory is on a per-context basis, 
> and I've only set the "basedir" for the entire `Tomcat` instance, 
> Tomcat must be determining a default temporary directory for the 
> context. Surely I'm allowed to explicitly specify a temporary 
> directory on a per-context basis, but I sure can't find it. The 
> `StandardContext` seems to equate the "temporary directory" with the 
> "work directory". Are they really the same? If so, I suppose I can 
> just call `((StandardContext)context).setWorkDir(String)`?


I decided to just change the `Tomcat` base directory to some location. 
This will let Tomcat create its own per-context temp subdirectory under 
this, and it lowers the risk that I'll wind up with still other unwanted 
temporary directories in my project, which is under source control.

It turns out there's another trick here as well. You have to call 
`tomcat.setBaseDir()` /before/ you call the magic 
`tomcat.getConnector()` (the latter of which secretly creates the 
default connector). Otherwise, if the connector is created first, Tomcat 
decides on its own base directory using the current working directory 
and something in the form `tomcat:8080` (which is apparently why I got 
that particular directory subtree in the first place).

Garret


Re: no temp directory creation wanted when embedding Tomcat

Posted by Garret Wilson <ga...@globalmentor.com>.
On 4/22/2019 7:58 AM, Mark Thomas wrote:
> On 21/04/2019 15:53, Garret Wilson wrote:
>> …
>> But now I realize Tomcat is creating this directory structur inside the
>> "base dir" I specified:
>>
>> tomcat.8080/work/Tomcat/localhost/ROOT
>>
>> I don't need this directory. I don't want this directory created. How do
>> I tell Tomcat not to create no danged directories?
> The Servlet specification requires (see section 4.8.1 of the Servlet 4.0
> spec) that Tomcat provides a private temporary directory for each
> servlet context (web application).


I have have several reactions.

1. The first is, OK, so the servlet spec requires that the servlet 
container expose a temporary directory. Tomcat can't provide a temporary 
directory to the consumer unless it has a temporary directory, so it's 
reasonable that it creates one.

2. But so far nothing has been stored in this directory, so it's 
completely unused. I see also in the `Tomcat` class the comment, "lazy 
init for the temp dir - only when a JSP is compiled or get temp dir is 
called we need to create it. This will avoid the need for the baseDir". 
It sounds like you're lazily creating the JSP temporary directory, so 
why can't we do the same for the context temporary directory, which may 
never be used (and frankly probably won't be used in many applications)? 
But OK, that's a quibble; my other thoughts are more pressing.

3. Since the temporary working directory is on a per-context basis, and 
I've only set the "basedir" for the entire `Tomcat` instance, Tomcat 
must be determining a default temporary directory for the context. 
Surely I'm allowed to explicitly specify a temporary directory on a 
per-context basis, but I sure can't find it. The `StandardContext` seems 
to equate the "temporary directory" with the "work directory". Are they 
really the same? If so, I suppose I can just call 
`((StandardContext)context).setWorkDir(String)`?


> The best you can do is specify an absolute path that already exists for
> the Context's work directory. It doesn't need to be writeable. If you
> are using it for multiple web applications you probably don't want it to
> be writeable.


Ah, OK—I had read that response earlier, but didn't understand exactly 
what it meant until I investigated and wrote #2 above. So I guess I was 
right: I need to call`((StandardContext)context).setWorkDir(String)`.

4. But all this "temporary directory requirement" business is for 
servlet containers. I started out just wanted to embed Tomcat to serve 
static files; I don't (yet? ever?) need a servlet container for this 
particular application. So how can I use Tomcat to serve static files 
without bringing in the requirements of a servlet container?

Maybe the answer is that Tomcat serves files by using a 
static-file-serving servlet, which in turn requires me to use Tomcat as 
a servlet container even for serving static files, which in turn 
requires me to have a temporary directory I don't want or need.

I suppose that's just the way it is. This is not so much a complaint as 
a desire to confirm I understand correctly how things stands. (OK, it's 
a teeny-tiny complaint, too.)

Garret


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


Re: no temp directory creation wanted when embedding Tomcat

Posted by Mark Thomas <ma...@apache.org>.
On 22/04/2019 14:37, Christopher Schultz wrote:
> Garret,
> 
> On 4/22/19 09:36, Christopher Schultz wrote:
>> Mark,
> 
>> On 4/22/19 06:58, Mark Thomas wrote:
>>> On 21/04/2019 15:53, Garret Wilson wrote:
>>>> As I mentioned in other emails, I am embedding Tomcat 9 (with 
>>>> OpenJDK 11 on Windows 10) to serve static files from
>>>> `/foo/bar`. Currently I'm not supporting Java webapps. I'm not
>>>> supporting JSP. I just want to serve static files.
>>>>
>>>> From your help in another thread, I called the magic 
>>>> "gets-but-really-creates-a-connection" method and got it 
>>>> working.
>>>>
>>>> But now I realize Tomcat is creating this directory structur 
>>>> inside the "base dir" I specified:
>>>>
>>>> tomcat.8080/work/Tomcat/localhost/ROOT
>>>>
>>>> I don't need this directory. I don't want this directory
>>>> created. How do I tell Tomcat not to create no danged
>>>> directories?
> 
>>> The Servlet specification requires (see section 4.8.1 of the 
>>> Servlet 4.0 spec) that Tomcat provides a private temporary 
>>> directory for each servlet context (web application).
> 
>>> The best you can do is specify an absolute path that already
>>> exists for the Context's work directory. It doesn't need to be
>>> writeable. If you are using it for multiple web applications you
>>> probably don't want it to be writeable.
> 
>> Could a <Resource> be used to map a virtual directory for the work 
>> directory? For example, trick Tomcat into using a "directory"
>> within a JAR file or something as the "work" directory? Obviously,
>> it will fail if Tomcat tries to write a temporary file, but that's
>> kind of the point.

No. Tomcat doesn't use the web app resources infrastructure to find the
work directory.

>> George, you can always use the "document-root" (to use httpd's 
>> parlance) as the work directory, since it also must exist.
> 
> ^^^^ I meant Garret. Sorry, I had just read a message posted by George
> Stanchev and his name was on my mind.

I wouldn't recommend that in the general case. I'd worry about conflicts
and/or stuff getting deleted by accident.

Mark

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


Re: no temp directory creation wanted when embedding Tomcat

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Garret,

On 4/22/19 09:36, Christopher Schultz wrote:
> Mark,
> 
> On 4/22/19 06:58, Mark Thomas wrote:
>> On 21/04/2019 15:53, Garret Wilson wrote:
>>> As I mentioned in other emails, I am embedding Tomcat 9 (with 
>>> OpenJDK 11 on Windows 10) to serve static files from
>>> `/foo/bar`. Currently I'm not supporting Java webapps. I'm not
>>> supporting JSP. I just want to serve static files.
>>> 
>>> From your help in another thread, I called the magic 
>>> "gets-but-really-creates-a-connection" method and got it 
>>> working.
>>> 
>>> But now I realize Tomcat is creating this directory structur 
>>> inside the "base dir" I specified:
>>> 
>>> tomcat.8080/work/Tomcat/localhost/ROOT
>>> 
>>> I don't need this directory. I don't want this directory
>>> created. How do I tell Tomcat not to create no danged
>>> directories?
> 
>> The Servlet specification requires (see section 4.8.1 of the 
>> Servlet 4.0 spec) that Tomcat provides a private temporary 
>> directory for each servlet context (web application).
> 
>> The best you can do is specify an absolute path that already
>> exists for the Context's work directory. It doesn't need to be
>> writeable. If you are using it for multiple web applications you
>> probably don't want it to be writeable.
> 
> Could a <Resource> be used to map a virtual directory for the work 
> directory? For example, trick Tomcat into using a "directory"
> within a JAR file or something as the "work" directory? Obviously,
> it will fail if Tomcat tries to write a temporary file, but that's
> kind of the point.
> 
> George, you can always use the "document-root" (to use httpd's 
> parlance) as the work directory, since it also must exist.

^^^^ I meant Garret. Sorry, I had just read a message posted by George
Stanchev and his name was on my mind.

- -chris
-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/

iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAly9w4kACgkQHPApP6U8
pFgMug/9EumrFwad/7G0+dpXfeeVxDuqByGP5Aw9fVjWW6FqKnoBfConGR2WQsnJ
07tvtt4wj6DJWSbOoXg1hhMcD+YWBmxgtoa2u4XaTf0hssfTr7pZhp/WVH/bt8l0
WdK3nMMQPf/7TNvDiuXRuubOdaj0Cl4AIIr4iC1aR8y3447GE/iQvlKnC0LRr2qd
cGiMXEuSzFKLvvU4zOkgeK8cbEGdvyUfKfWkQTolQ0ytahGRAdOjMsv3yzwWT8v7
+JQ7VrNlE3y9VAm5FtyA69Ez62fIR9NkMWDocDoHTDJAmw52msuRX1dwJSAFVNvh
4rm7F2ZSfVWavrFzhtZFmNMW9FbV+CCWRngvevN2TtV1bUcizpTB1xZ3dRh9Yy4T
mf3I5OD8+2t/o+w8Q9+TsDwAhp+LexwgzpAfpQAsrRt1EnKx6MhapFQS2bgJi6bA
LTxq5wIVw6hhgKyBSgdovi0cgDc55udustnwMNiz6G6Sr61R0gX2I1ssuWBbnmwq
Xg0gbEGueYxTRMiM6w4wv/VO4iKDN9mduW/f2yeckSKCKIjoUWyCJzJddLSO5hMN
YW2VtoJqEeVcf9agym6C9vq1GMH4wQ5lsuD07tn7RWMI5JcKqRZl/vWDhAOLZ6qJ
4T8J/2xzVYTecBLPdjwrX37N5hWonwJEl7u1zP2swUQBML3eJWA=
=AIUk
-----END PGP SIGNATURE-----

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


Re: no temp directory creation wanted when embedding Tomcat

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Mark,

On 4/22/19 06:58, Mark Thomas wrote:
> On 21/04/2019 15:53, Garret Wilson wrote:
>> As I mentioned in other emails, I am embedding Tomcat 9 (with
>> OpenJDK 11 on Windows 10) to serve static files from `/foo/bar`.
>> Currently I'm not supporting Java webapps. I'm not supporting
>> JSP. I just want to serve static files.
>> 
>> From your help in another thread, I called the magic 
>> "gets-but-really-creates-a-connection" method and got it
>> working.
>> 
>> But now I realize Tomcat is creating this directory structur
>> inside the "base dir" I specified:
>> 
>> tomcat.8080/work/Tomcat/localhost/ROOT
>> 
>> I don't need this directory. I don't want this directory created.
>> How do I tell Tomcat not to create no danged directories?
> 
> The Servlet specification requires (see section 4.8.1 of the
> Servlet 4.0 spec) that Tomcat provides a private temporary
> directory for each servlet context (web application).
> 
> The best you can do is specify an absolute path that already exists
> for the Context's work directory. It doesn't need to be writeable.
> If you are using it for multiple web applications you probably
> don't want it to be writeable.

Could a <Resource> be used to map a virtual directory for the work
directory? For example, trick Tomcat into using a "directory" within a
JAR file or something as the "work" directory? Obviously, it will fail
if Tomcat tries to write a temporary file, but that's kind of the point.

George, you can always use the "document-root" (to use httpd's
parlance) as the work directory, since it also must exist.

- -chris
-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/

iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAly9w1sACgkQHPApP6U8
pFiGPBAAujnlk8kSIZQUUe5ydJZuU4TMvzn0NFFcE3zetldHklQ3HNSgCAff5s7D
oNbHHiGKRiS1fDaa4hUSePdsZZcnwGlfzEZdIbn05NFZLl7OCASiH1F4FS+hW0cf
vBGfVGOdPIDHGaIFGeTDi28ADi2TP1RoHLdCNHJK1Ul/bbesiw9vKvPkyRfY6g7X
+OPzWY/p7Ke0Q3JvGQISVplRkKZ6HtYtCIo3k0nMciE2RNZUIsIC3451rQD4vjxo
Bn+ZZZkP56Ff0Xzxc18Fx9Yut+4RV+SpVbESHc+q45YtlGIrYQi/QMvTJ3ZpGN4u
6me+t5CZvqnxgwQOSKFzXtijaPdS9awtlqmhSLKT5hSc/kGpkhjKs2Nie6faZcs2
7WPMzJu6JqRW93j0NtE1V7cPmvozKlaKCjMRaRB8XCv25vpePGZ9YKwTq5C7GNqX
++h1f/s2BWsbFshlfF6KRCov5nNi/eHNKHSMUz4JBKzc+mzabTCqE7TGWIbxeJtA
mJ8UUzyMzaigTY0THduRrwQbTECbTBwGpbXf2m4fP0XF6rKNRepzG4j8XD/bTFQP
fp3oEYUAOYms+TGd/fYlvTNUQHm3S2PpM4Y868KfHm3kCPREdLXnqfjTWtBj+WdF
DSkMgoHj09hJ69njFvuThqQ99wJbtIhu8wg6oNf5TvD7ghXdOKk=
=Gx4M
-----END PGP SIGNATURE-----

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


Re: no temp directory creation wanted when embedding Tomcat

Posted by Mark Thomas <ma...@apache.org>.
On 21/04/2019 15:53, Garret Wilson wrote:
> As I mentioned in other emails, I am embedding Tomcat 9 (with OpenJDK 11
> on Windows 10) to serve static files from `/foo/bar`. Currently I'm not
> supporting Java webapps. I'm not supporting JSP. I just want to serve
> static files.
> 
> From your help in another thread, I called the magic
> "gets-but-really-creates-a-connection" method and got it working.
> 
> But now I realize Tomcat is creating this directory structur inside the
> "base dir" I specified:
> 
> tomcat.8080/work/Tomcat/localhost/ROOT
> 
> I don't need this directory. I don't want this directory created. How do
> I tell Tomcat not to create no danged directories?

The Servlet specification requires (see section 4.8.1 of the Servlet 4.0
spec) that Tomcat provides a private temporary directory for each
servlet context (web application).

The best you can do is specify an absolute path that already exists for
the Context's work directory. It doesn't need to be writeable. If you
are using it for multiple web applications you probably don't want it to
be writeable.

Mark

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