1
votes

Apologies for the newbie question, I am trying to start using Jetty servlet container for a Scala/Ajax application. I want to change the default webapp directory to a custom one, say /home/myuser/project/ and let jetty serve the index of that page.

a doctype, head and body is literally all I need as all the layout will be controlled via Ajax/REST/Scala with DOM generated entirely in JavaScript.

How can I get jetty to serve a custom index.html file from a specified folder?

I am using Jetty 9 Debian Distribution on a 64 bit Ubuntu 12.10, if that makes a difference in any way.

1
i am intrigued by the 'Jetty 9 Debian Distribution'...can you provide a link? - jesse mcconnell
ah ok, just the distribution, thought someone was making a .deb I didn't know about, thanks - jesse mcconnell

1 Answers

1
votes

I believe you should be able to add a file called root.xml to your $JETTY_HOME/contexts directory with the content:

<?xml version="1.0"  encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://\
jetty.mortbay.org/configure.dtd">

<Configure class="org.mortbay.jetty.webapp.WebAppContext">
  <Set name="contextPath">/</Set>
  <Set name="resourceBase">
    /home/myuser/project/
  </Set>
</Configure>

You may also need to remove any existing wars in $JETTY_HOME/webapps that respond to the same context.