I have a pressing need to allow files to be accessed that are static.
Unfortunately, there's a web application sitting on my root context ("/").
So I need to define alternate docroots1.
Unfortunately, this seems to be a specific Glassfish or Payara configuration.
As it is bad form, to put this in my code base (who knows where my wars will end up someday), it's better if I put it in the domain.xml file.
That way it's application server dependent, instead of war dependent.
However, I have found the following2:
virtual server's alternate docroots are considered only if a request does not map to any of the web modules deployed on that virtual server. A web module's alternate docroots are considered only once a request has been mapped to that web module.
Which means that an alternative docroot on the virtual server is basically unusable if you have a webapplication situated at your context root "/".
As an example consider the following:
Microprofile Config
Now, I don't much like putting pathnames in my web modules. So I was wondering if it's possible to change that by using Microprofile Config.
And it is3!
It will look something like this:
Other application servers
Other application servers have similar options (of which I know nothing).
In WildFly or the EAP4, it is possible to add another file handler and another location to the undertow subsystem in standalone.xml.
References
- [1] A programmer's blog - Map an external directory into Glassfish
- http://harkiran-howtos.blogspot.com/2009/08/map-external-directory-into-glassfish.html
- [2] Sun GlassFish Enterprise Server v3 Prelude Developer's Guide - Alternate Document Roots
- https://docs.oracle.com/cd/E19776-01/820-4496/geqpl/index.html
- [3] Payara Community Documentation - Types of variable references
- https://docs.payara.fish/community/docs/5.2020.7/documentation/payara-server/server-configuration/var-substitution/types-of-variables.html
- [4] StackOverflow - How to configure Wildfly to serve static content (like images)?
- https://stackoverflow.com/questions/22684037/how-to-configure-wildfly-to-serve-static-content-like-images
No comments:
Post a Comment