-----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-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org