Jetty context

The Jetty context files are used to configure your Web app in Jetty. It not necessary to define it but is more convenient to better control your application

Example file

The file below is an example to define the context of a Berlioz on a local Jetty installation.

<?xml version="1.0"  encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd"
[
  <!ENTITY berlioz.webapp "example">
  <!ENTITY berlioz.domain "example.localhost">
]>

<!-- ==================================================================
  This is a template file for the local deployment of a Berlioz
  application, it is usually sufficient to simply update the entity
  definitions at the top of this file.
===================================================================== -->

<Configure class="org.eclipse.jetty.webapp.WebAppContext">

  <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  <!-- Required minimal context configuration :                        -->
  <!--  + contextPath                                                  -->
  <!--  + war OR resourceBase                                          -->
  <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  <Set name="contextPath">/</Set>
  <Set name="resourceBase"><SystemProperty name="jetty.home" default="."/>/../../webapps/&berlioz.webapp;</Set>

  <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  <!-- Optional context configuration                                  -->
  <!-- o It can be useful to use a different web descriptor to set up  -->
  <!--   caching, allow Berlioz to server welcome files servlets,      -->
  <!--   prevent file locking on Windows, etc...                       -->
  <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  <Set name="copyWebDir">false</Set>
  <Set name="defaultsDescriptor"><SystemProperty name="jetty.base" default="."/>/etc/webdefault.xml</Set>

  <!-- Enable symlinks -->
  <Call name="addAliasCheck">
    <Arg><New class="org.eclipse.jetty.server.handler.AllowSymLinkAliasChecker"/></Arg>
  </Call>

  <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  <!-- Virtual hosts                                                   -->
  <!-- o Use 'localhost' for development and if this the only Web app  -->
  <!-- o Use a subdomain if there are multiple Web applications        -->
  <!--   (don't forget to update your system's host file)              -->
  <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  <Set name="virtualHosts">
    <Array type="String">
      <Item>&berlioz.domain;</Item>
    </Array>
  </Set>

  <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  <!-- Persistent sessions                                             -->
  <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  <Set name="sessionHandler">
    <New class="org.eclipse.jetty.server.session.SessionHandler">
      <Arg>
        <New class="org.eclipse.jetty.server.session.HashSessionManager">
          <Set name="storeDirectory"><Property name="jetty.base" default="."/>/sessions/&berlioz.webapp;/</Set>
          <Set name="lazyLoad">true</Set>
          <Set name="deleteUnrestorableSessions">true</Set>
        </New>
      </Arg>
    </New>
  </Set>

  <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  <!-- Add context specific logger                                     -->
  <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  <New class="java.io.File">
    <Arg><Property name="jetty.logs" default="./logs"/>/&berlioz.webapp;/</Arg>
    <Call name="mkdirs"/>
  </New>
  <Set name="handler">
    <New id="RequestLog" class="org.eclipse.jetty.server.handler.RequestLogHandler">
      <Set name="requestLog">
        <New id="RequestLogImpl" class="org.eclipse.jetty.server.NCSARequestLog">
          <Set name="filename"><Property name="jetty.logs" default="./logs"/>/&berlioz.webapp;/berlioz-yyyy_mm_dd.request.log</Set>
          <Set name="filenameDateFormat">yyyy_MM_dd</Set>
          <Set name="append">true</Set>
          <Set name="retainDays">30</Set>
          <Set name="LogTimeZone">Australia/Sydney</Set>
        </New>
      </Set>
    </New>
  </Set>

</Configure>

Created on , last edited on