jetty.xml is a Lycia configuration file (= a servlet container) used for configuring Jetty web server embedded in LyciaStudio.
With Jetty, jetty.xml can be used to configure:
In Lycia, jetty.xml is most often used to specify the location for your public client-side resources which will be used in LyciaStudio.
When you uninstall Lycia with QPM, LyciaStudio configuration folders are deleted.
This means that you must back up your jetty.xml before uninstalling Lycia. Otherwise, it will be deleted.
Querix Package Manager doesn't create jetty.xml.
So, if you want to work with public client-side resources in LyciaStudio, you must first create this file.
To create jetty.xml, please follow these steps.
Step 0. Close LyciaStudio (if running).
Step 1. Stop Lycia Web Server.
Step 2. Open your favorite text editor.
Step 3. Copy the template given below to a new text file.
This is the context configuration block you must uncomment:
<!--
<New id="..." class="org.eclipse.jetty.server.handler.ContextHandler">
<Set name="contextPath">...</Set>
<Set name="handler">
<New class="org.eclipse.jetty.server.handler.ResourceHandler">
<Set name="resourceBase">...</Set>
<Set name="directoriesListed">true</Set>
</New>
</Set>
</New>
-->
Step 5. In this block, change the id, context path, and resource base.
<Item>
<Ref refid = "context"/>
</Item>
We recommend using these folders to save your custom configuration files:
If you want to save your configuration files to any other – non-default – folder/s, you must specify it (or them) in LYCIA_CONFIG_PATH.
Step 6. Start Lycia Web Server.
Step 9. Start LyciaStudio.
You have to restart Lycia Web Server every time when you update your existing jetty.xml as well.
You can specify several folders for your public client-side resources. But these folders must be defined one-by-one in its separate context configuration block and need one new handler for each folder.
jetty.xml is a file with a strict structure. This means that all its tags are compulsory and only some of them can be configured.
Here is a template of your future jetty.xml.
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd">
<Configure id="JettyServer"class="org.eclipse.jetty.server.Server">
<Set name="connectors">
<Array type="org.eclipse.jetty.server.Connector">
<Item>
<New class="org.eclipse.jetty.server.ServerConnector">
<Arg><Ref refid="JettyServer"/></Arg>
<Set name="port">8787</Set>
</New>
</Item>
</Array>
</Set>
<!--
<New id="..." class="org.eclipse.jetty.server.handler.ContextHandler">
<Set name="contextPath">...</Set>
<Set name="handler">
<New class="org.eclipse.jetty.server.handler.ResourceHandler">
<Set name="resourceBase">...</Set>
<Set name="directoriesListed">true</Set>
</New>
</Set>
</New>
-->
<Set name="handler">
<New id ="contextHandlerConnection" class="org.eclipse.jetty.server.handler.HandlerCollection">
<Set name="handlers">
<Array type="org.eclipse.jetty.server.Handler">
<!--
<Item>
<Ref refid="context" />
</Item>
-->
</Array>
</Set>
</New>
</Set>
</Configure>
There are only four customizable tags in this template:
id or refid |
is the identifier of the context |
name="contextPath" |
is a URL prefix that identifies the context to which the incoming request is passed. If the contextPath is /public, the webserver will handle requests to /public/lycia.png, /public/images/, and /public/images/lycia.png but will not handle requests to /, /images, or /images/lycia.png. |
name="resourceBase" |
is a folder that stores public client-side resources |
Here is an example of how you can change these tags:
<New id="context" class="org.eclipse.jetty.server.handler.ContextHandler">
<Set name="contextPath">/public</Set>
<Set name="handler">
<New class="org.eclipse.jetty.server.handler.ResourceHandler">
<Set name="resourceBase">C:\ProgramData\Querix\Lycia\progs\public</Set>
<Set name="directoriesListed">true</Set>
</New>
</Set>
</New>
<Set name="handler">
...
<Item>
<Ref refid="context"/>
</Item>
...
</Set>