On Jan 23, 2015, at 3:27 AM, Andy Bunce wrote:
Michael,
As Christian suggests the web.xml from GraphXQ does date from the old default basexhttp configuration (~basex 7.8?). Initially I was unconvinced by the change to what is the current default configuration but I have grown to appreciate it.
I see the advantages of not having to start all RESTXQ requests with the string '/restxq/', and would prefer it. The more a URI exposes the mechanisms used by the implementation to handle the requests, the harder it is, later, to change the implementation without breaking the old URIs.
My difficulty was that I was unable to get the current default web.xml configuration to serve any static resources at all.
After a bit more experiment, I see now that part of my problem was a false analogy with the way the prefix patterns /rest/*, /restxq/*, and /webdav/* behave: they strip off the prefixes '/rest/', '/restxq/', or '/webdav/' and look for resources matching the remainder of the URI path. By analogy, I guessed that the default servlet, matching '/static/*', would strip off '/static/' and look for a resource (here a file in the file system) with a path that matches the remainder of the URI. It did not occur to me until this morning that Jetty (or the default servlet, or whoever is responsible) might not be stripping off the prefix, and instead might be looking for a directory named 'static' in the file system. I would prefer to avoid this for the same reasons I'd like to avoid having '/restxq/' in the URI. A fixed prefix is probably not too bad if there are directories which contain only static content, and if the static content is all contained in such directories.
My confusion was only exacerbated by the fact that the servlet spec says
The first successful match is used with no further matches attempted
which I misunderstood to mean 'first in textual order', making me wonder how, if the pattern /* is specified first, any other pattern is ever matched. Reading the passage again, in the light of the experiments I just did, makes me think it means 'first encountered in the algorithm not very clearly specified below'.
The nice thing is that once you understand the web.xml configuration you can choose either style.
Yes. I rather wish understanding the web.xml configuration file had not required quite so much of my time, or cost me quite so many gray hairs. But understanding it will be very useful, I hope. (Assuming that I do, finally, understand it correctly.)
Many thanks to both Christian and Andy for their help. If time permits, I hope to take up Christian's challenge and contribute some words on the web.xml configuration, for use in the documentation.