Database Reference
In-Depth Information
Global Error Pages
When something goes wrong, eXist generates an error page with the appropriate
HTTP status code—for instance, a page with status
500
for an XQuery script that
contains an error, or a status
404
for a nonexistent resource. You might want to pre‐
vent the user from seeing this and redirect these error responses to some kind of
“Oops, sorry” page.
Unfortunately, eXist has no means of defining these kinds of error pages on an appli‐
cation level. You can only define them at the Jetty level, making them global for the
full eXist instance.
To add an error page, edit the
$EXIST_HOME/webapp/WEB-INF/web.xml
file and
add the following XML fragment as a child of the root
web-app
node:
<error-page>
<error-code>
http-error-code
</error-code>
<location>
uri-to-error-page
</location>
</error-page>
The
error-code
element contains the integer HTTP status code you want to
catch (e.g.,
500
or
404
).
The
location
element contains the URL to the page you want to display if such
an error pops up. This must be the part of a valid eXist URL that comes after
/
exist
. For instance:
/rest/db/central/page404.xq
.
So, if your
web.xml
file contains:
<error-page>
<error-code>
404
</error-code>
<location>
/rest/db/central/page404.xq
</location>
</error-page>
all responses with an HTTP
404
status code will be forwarded to the
page404.xq
script.
Note that you have to restart eXist for the changes to take effect.
Building Applications with RESTXQ
RESTXQ is a standard developed by the
EXQuery community
that allows you to
declare interactions between HTTP requests and XQuery functions. RESTXQ takes a
very different approach from that of XQuery URL rewriting in eXist, instead using
XQuery 3.0 annotations to declare your HTTP intentions within function declara‐
tions. XQuery functions that declare RESTXQ annotations are known as
resource
functions
due to the fact that they expose some sort of resource over HTTP.
Search WWH ::
Custom Search