The operation mode can be configured as explained further below.
'''Note:''' if the web application stores data in the local file system of the servlet container, then by default it will use a separate directory as home directory. This is because, in many production environments, the servlet container runs as a dedicated user without a {{MonoCode|$HOME}} directory. However BaseX needs to store somewhere it's settings and data. This is why, even when running a servlet container with a normal user (i.e. one which has a {{MonoCode|$HOME}} directory), the web application will not use by the default the settings stored in {{MonoCode|$HOME/.basex}} and will have a different set (or empty set) of databases than the one in the case of the standalone HTTP server. However, this behavior can be changed by manually setting the BaseX home directory to {{MonoCode|$HOME}}, in which case the web application will use the same databases as in the case of the standalone server.
==Configuring Available Services==
To enable or disable one of the provided services, the corresponding servlet entry in the {{MonoCode|web.xml}} file needs to be removed/commented. The default URL paths are listed in the following table:
{| class="wikitable"
|- valign="top"
| REST
| {{MonoCode|<nowiki>http://[host]:[port]/[servlet_context_path]/rest</nowiki>}}
| access XML database and its resources, see [[REST]]
|- valign="top"
| RESTXQ
| {{MonoCode|<nowiki>{{MonoCode|http://[host]:[port]/[servlet_context_path]/restxq</nowiki>}}
| create XQuery Web Services, see [[RESTXQ]]
|- valign="top"
| WebDAV
| {{MonoCode|<nowiki>http://[host]:[port]/[servlet_context_path]/webdav</nowiki>}} or<br/>{{MonoCode|<nowiki>webdav://[host]:[port]/[servlet_context_path]/webdav</nowiki>}} (depending on client)
| access databases via the filesystem, see [[WebDAV]]
|- valign="top"
| Web Server
| {{MonoCode|<nowiki>http://[host]:[port]/[servlet_context_path]</nowiki>}}
| access your standard web files (e.g. HTML, JavaScript or CSS).
|}
==Configuring Database Access==
The following options are available to configure the way the databases are accessed. These can be set in the {{MonoCode|web.xml}} file or as Java system variables (e.g. using <code>-Dorg.basex.mode=client</code> from the command line).
{| class="wikitable"
|- valign="top"
! Description
|- valign="top"
| {{MonoCode|org.basex.mode}}| {{MonoCode|local}}| Operation mode. By default, the value is "{{MonoCode|local}}": the servlets will access and store data locally using {{MonoCode|org.basex.path}}. If "{{MonoCode|client}}" is specified, all operations are performed on a remote server instance (the login data of which is stored in the {{MonoCode|.basex}} configuration file).
|- valign="top"
| {{MonoCode|org.basex.user}}
| -
| Database user. By default, no value is specified, and the credentials must be specified by the client. Note that it is a clear security risk to store user credentials in the {{MonoCode|web.xml}} file. The default user credentials can be found under [[Startup#BaseX_Client|Startup: BaseX Client]].
|- valign="top"
| {{MonoCode|org.basex.password}}
| -
| Database user password.
|}
Additionally, all database main options, which are usually stored in the {{MonoCode|.basex}} configuration file ({{MonoCode|DBPATH}}, {{MonoCode|HTTPPATH}}, etc.), can be specified as well by prefixing the key with {{MonoCode|org.basex.}}. If an option references a relative path, it will be prefixed with the servlet root path. Some examples follow:
<pre class="brush:xml">
<context-param>
</pre>
How to set these options in the {{MonoCode|web.xml}} of the BaseX web application is specific to the servlet container. For example, in Jetty it is done using [http://docs.codehaus.org/display/JETTY/override+web.xml an overriding web.xml]. Another option is to directly edit the {{MonoCode|WEB-INF/web.xml}} file in the WAR archive (WAR files are simple ZIP files).
=Maven=
==Configuration==
The same options as in the case of deployment in a servlet container apply. In this case, however, there is no WAR archive. Instead, Jetty uses the directory {{MonoCode|basex-api/src/main/webapp}}. For configuring various Jetty runtime options, such as port, context path, etc. refer to the [http://docs.codehaus.org/display/JETTY/Maven+Jetty+Plugin Maven Jetty Plugin]. These should be entered in the {{MonoCode|pom.xml}} file of the {{MonoCode|basex-api}} project.
=Standalone Application=