tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <ch...@christopherschultz.net>
Subject Re: programmatically setting MIME mappings for static-only site
Date Fri, 19 Apr 2019 20:12:13 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Garret,

On 4/19/19 15:12, Mark Thomas wrote:
> On April 19, 2019 4:20:24 PM UTC, Garret Wilson
> <garret@globalmentor.com> wrote:
>> I'm wanting to embed Tomcat to only serve static files (for the 
>> moment). That is, no JSP, etc. I also want to have the welcome
>> files completely customizable.
>> 
>> So instead of calling `tomcat.addWebapp()`, I go the completely 
>> programmable route and call `tomcat.addContext()`, 
>> `context.createWrapper()`, etc. This makes my bypass the 
>> `DefaultWebXmlListener`, which would have called 
>> `initWebappDefaults(Context ctx)` to set up the welcome files and
>> such myself.
>> 
>> But `initWebappDefaults()` also sets up the default MIME
>> mappings. And `Tomcat.DEFAULT_MIME_MAPPINGS` is private.
>> 
>> So the situation seems to be that Tomcat forces me to choose
>> between creating a full-fledged JSP server, or setting up all the
>> MIME types with some list of my own. Maybe it would be good for
>> me to have my own list eventually, but for now this seems like an
>> artificial choice forced upon me.
>> 
>> Part of the problem seems to be that the (ancient?) code has the
>> MIME mappings as a string array!! Heaven knows we don't want to
>> expose that.
>> 
>> It should really be turned into a read-only map and then exposed
>> so we can use it.
>> 
>> Then of course I see the comment:
>> 
>>> TODO: would a properties resource be better ? Or just parsing
>> /etc/mime.types ?
>> 
>> To answer part of that question, we can't just parse
>> `/etc/mime.types` because the embedded server might not even have
>> an `/etc/mime.types` file. This should definitely be put into a
>> properties resource, I would
>> 
>> think.
>> 
>> So I've probably answered my own question; this is an old TODO
>> that needs to be done, I suppose?
> 
> Yep.

+1

This is a perfect "beginner" enhancement.

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

iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAly6K5wACgkQHPApP6U8
pFhxyRAAw2AkPD1gtbc9/0poWuZrJMBLeDY41G13V+3VGwAu+YsBTpUmyh24lv/6
YOjGiNLYvqYLoKMx//obH/dwK38OwzZVJcS6z91ip9E5Unu2s++X3tNlOh98+C69
xCIc09Q/9B4jCIwA2NrgQY5KBqRk6wPm+xcG6EvCBJ8jijDkaw9qs9TkvUI26sIs
6JR24wR6YipTG6r4DTpHl8Z0ltbgEA14rws9TvQUWvODizvFVEZroSVtIsF6NYBB
wiiA+JPuvcWHyouxoQCLtrTELkcAX2F7RskY+vaH8Yvr4lUiX+P6mPHuLh9X/CLF
yoaks+zc/wPiaGiECh08zw6d5HFvwvM7cseLWhDO+PCVj2HsoIxxLniaBRWmYF5t
QPdRFIc83Gz5Aq6TUNyxjIqNXZnN5Fz1pvxWitSK671APKLzpqI27mf90GF9+gqL
VVbROKlfpzacE98pv7UHeKT9v0rEo1Ramw29BwpshtDvhVgEIrcMID0/ExDdct4W
bd4NUY1PEW3ykB0HVKCDEPPQVecbuNEYFe7tgtxO8YZqq1adyZmGCQffaQEpa7z0
mWKBa8JAFDpDS2sQMDlLP2Lddu1z2wW8izdWt5ArFCSGZQpVJQh7XQY41Fy7bB0y
5lH7htGK0S2CrvX7UT4JpmNbvtQ1b4K/hb1wKI3O/ljKnUKXDNs=
=B/mc
-----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