On Thu, Dec 30, 2021 at 03:16:51PM -0500, Michael B Allen wrote: > On Thu, Dec 30, 2021 at 10:57 AM Christopher Schultz > <ch...@christopherschultz.net> wrote: > > > > You mean like ServletContext.getRealPath? > > Honestly I'm not sure how I feel about getRealPath. On the one hand, I > don't think it's reasonable to just pretend that applications only > exist in the vacuum of space. There are many practical reasons why an > application might want to interact with the filesystem but without > requiring absolute paths. Just because there might not be a file > system is a weak excuse to not properly account for one. Being able to > update a file of properties for example and have the application see > that the file is updated without reloading the webapp (maybe even if > the app is packaged as a war) is very useful. On the other hand I > don't think I would want another 10 classes just to create some kind > of ancillary webapp storage abstraction.
I would say that servlet code should, in general, assume that nothing exists outside of the container except that which it is told about. It should not care where it is. If it needs to interact with a filesystem, it should be given paths into that filesystem as context parameters or environment objects. If I intended to make changes to an application's configuration without re-deploying, I would put the configuration elsewhere and configure the context with a path (or a Path) to it. You may wish to have a look at https://stackoverflow.com/a/12160863/2916377 -- 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
signature.asc
Description: PGP signature