public.xml is a Lycia configuration file (= a servlet container) intended for configuring Lycia Web Server (Jetty) used for runtime.
More specifically, public.xml is a Lycia configuration file where you specify the location for your public client-side resources which will be used at runtime.
This means that if you need/want to locate your runtime public client-side resources in different folders, you must create several public.xml files.
Querix Package Manager doesn't create public.xml.
So, if you want to work with public client-side resources at runtime, you must first create this file.
To create public.xml, please follow these steps.
Step 0. Stop Lycia Web Server.
Step 1. Open your favorite text editor.
Step 2. Copy the template given below to a new text file.
Step 3. Specify the context path.
Step 4. Specify the resource base.
Step 6. Start Lycia Web Server.
You have to restart Lycia Web Server every time when you update your existing public.xml as well.
public.xml is a convention name used in this documentation.
We call this file public.xml because it is used to work with public client-side resources.
However, the name of the file is not significant – Lycia Web Server (Jetty) will load every file that has the definite structure and is saved in its folder.
We recommend you to follow this convention – and call your files public.xml, public2.xml, public3.xml. If you do, it will not change your development procedures or increase the performance of your applications. But it will help you better understand our examples and explanations.
public.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 that you must follow every time then you create new public.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">
<Configure 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>
</Configure>
There are only two customizable attributes in this template:
name="contextPath" |
is a URL prefix that identifies the context to which the incoming request is passed. If the contextPath is /public, the web server 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 |
The folder you specify as your resource base is not created automatically must already exist on your machine.
If you specify a non-existing folder, the webserver will not be create it and will fail to find it.
Here are two examples of how you can change your basic template:
when your client-side resources are stored on your machine:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">
<Configure class="org.eclipse.jetty.server.handler.ContextHandler">
<Set name="contextPath">/pc_images</Set>
<Set name="handler">
<New class="org.eclipse.jetty.server.handler.ResourceHandler">
<Set name="resourceBase">C:\ProgramData\Querix\Lycia\progs\public\images</Set>
<Set name="directoriesListed">true</Set>
</New>
</Set>
</Configure>
when your client-side resources are taken from a web-site:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">
<Configure class="org.eclipse.jetty.server.handler.ContextHandler">
<Set name="contextPath">/web_images</Set>
<Set name="handler">
<New class="org.eclipse.jetty.server.handler.ResourceHandler">
<Set name="resourceBase">http://company_site.com/products/books/downloads</Set>
<Set name="directoriesListed">true</Set>
</New>
</Set>
</Configure>